Dotfiles_nvim/lua/toolchain/go.lua

39 lines
1.1 KiB
Lua
Raw Normal View History

2024-09-07 18:39:22 +00:00
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('go', 'gomod', 'gosum', 'gotmpl')
T.add_null_ls_module(function(null_ls)
return {
-- Actions
null_ls.builtins.code_actions.gomodifytags,
null_ls.builtins.code_actions.impl,
-- Diagnostics
null_ls.builtins.diagnostics.golangci_lint,
null_ls.builtins.diagnostics.staticcheck,
-- Formatter
null_ls.builtins.formatting.gofumpt,
}
end)
T.add_lsp_autoinstalls('gopls')
T.add_lsps(function(lspconfig, capabilities)
lspconfig.gopls.setup({ capabilities = capabilities })
end)
T.add_plugins({
'leoluz/nvim-dap-go',
config = function()
local dir = require('util.finder').find_project_dir(
'go.mod',
3,
{ 'src', 'app', 'pkg' },
{ 'test' },
true
)
require('dap-go').setup({ delve = { cwd = dir } })
end,
})
end
return M