feat(go): organise imports on save

This commit is contained in:
Dan Anglin 2023-05-17 22:37:30 +01:00
parent f1046c2a1f
commit 2893ebee96
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
4 changed files with 12 additions and 5 deletions

View file

@ -1,4 +1,4 @@
.PHONY: backup clean update install_packer package publish
.PHONY: backup clean update install_lazy package publish
backup:
@bash ./.helpers/config backup

View file

@ -1,3 +1,4 @@
require("options")
require("plugins")
require("keymappings")
require("autocommands")

View file

@ -0,0 +1,6 @@
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*.go',
callback = function()
vim.lsp.buf.code_action({ context = { only = { 'source.organizeImports' } }, apply = true })
end
})

View file

@ -72,8 +72,8 @@ lspconfig.golangci_lint_ls.setup{
-- Jsonnet
lspconfig.jsonnet_ls.setup{
on_attach = custom_attach,
cmd = {"jsonnet-language-server", "--lint"},
flags = lsp_flags,
cmd = {"jsonnet-language-server", "--lint"},
flags = lsp_flags,
}
-- Terraform
@ -82,7 +82,7 @@ lspconfig.terraformls.setup{
cmd = {"terraform-ls", "serve", "-log-file="..log_directory.."/terraformls.log"},
filetypes = {"terraform", "hcl", "tf"},
root_dir = lspconfig.util.root_pattern{".terraform", ".git", "main.tf"},
flags = lsp_flags,
flags = lsp_flags,
}
-- Python
@ -90,7 +90,7 @@ lspconfig.pylsp.setup{
on_attach = custom_attach,
cmd = { "pylsp" },
filetypes = { "python" },
flags = lsp_flags,
flags = lsp_flags,
}
-- Lua