1
0
Fork 0

formatter: add and set up on save

This commit is contained in:
Felipe 2023-04-14 22:08:41 -04:00
parent b023bca11f
commit 0080ca78f2
Signed by: pitbuster
SSH key fingerprint: SHA256:HDYu2Pm4/TmSX8GBwV49UvFWr1Ljg8XlHxKeCpjJpOk
3 changed files with 21 additions and 2 deletions

3
.gitmodules vendored
View file

@ -91,3 +91,6 @@
[submodule "pack/general/start/telescope-luasnip.nvim"]
path = pack/general/start/telescope-luasnip.nvim
url = https://github.com/benfowler/telescope-luasnip.nvim
[submodule "pack/general/start/formatter.nvim"]
path = pack/general/start/formatter.nvim
url = https://github.com/mhartington/formatter.nvim

View file

@ -109,7 +109,21 @@ ts.setup({
---- Filetypes ---
vim.filetype.add({ extension = { kdl = "kdl" } })
---- formatter.nvim ----
local formatter = require("formatter")
formatter.setup({
filetype = {
lua = {
require("formatter.filetypes.lua").stylua,
},
python = {
require("formatter.filetypes.python").isort,
},
["*"] = {
require("formatter.filetypes.any").remove_trailing_whitespace,
},
},
})
---- LSP ----
local lsp = require("lspconfig")
@ -130,7 +144,7 @@ local on_lsp_attach = function(client, bufnr)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
vim.keymap.set("n", "<Leader>q", vim.diagnostic.setloclist)
vim.keymap.set("n", "<F3>", function()
vim.lsp.buf.format { async = true }
vim.lsp.buf.format({ async = true })
end)
end
@ -156,6 +170,7 @@ local servers = {
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
callback = function()
vim.lsp.buf.format()
cmd("Format")
end,
})

@ -0,0 +1 @@
Subproject commit 9c44c9d80863aef1cef5b5c354c393ed5d74e634