nvim config

This commit is contained in:
Felipe M 2024-01-31 11:26:31 +01:00
parent cdfac4d089
commit 9051320319
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
13 changed files with 399 additions and 0 deletions

View file

@ -0,0 +1,34 @@
local none_ls = require("null-ls")
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local opts = {
sources = {
-- gomft
none_ls.builtins.formatting.gofmt,
-- goimports-reviser (https://github.com/incu6us/goimports-reviser)
none_ls.builtins.formatting.goimports_reviser,
-- golangci-lint
none_ls.builtins.diagnostics.golangci_lint,
},
on_attach = function(client, bufnr)
-- check if there's any commands pre-running on the current buffer,
-- clear those and then run out own format command
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({
group = augroup,
buffer = bufnr,
})
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function ()
vim.lsp.buf.format({ bufnr = bufnr })
end
})
end
end,
}
return opts