formatter: add and set up on save
This commit is contained in:
parent
b023bca11f
commit
0080ca78f2
3 changed files with 21 additions and 2 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -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
|
||||
|
|
|
|||
19
init.lua
19
init.lua
|
|
@ -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,
|
||||
})
|
||||
|
||||
|
|
|
|||
1
pack/general/start/formatter.nvim
Submodule
1
pack/general/start/formatter.nvim
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 9c44c9d80863aef1cef5b5c354c393ed5d74e634
|
||||
Loading…
Add table
Reference in a new issue