nvim config
This commit is contained in:
parent
cdfac4d089
commit
9051320319
13 changed files with 399 additions and 0 deletions
34
.dotfiles/nvchad/custom/configs/none-ls.lua
Normal file
34
.dotfiles/nvchad/custom/configs/none-ls.lua
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue