Dotfiles_nvim/lua/toolchain/go.lua
2024-09-08 01:50:39 +02:00

43 lines
1.3 KiB
Lua

local T = require('toolchain')
local C = require('util.const')
local CONFIG = require('util.config')
local M = {}
function M.setup()
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 args = CONFIG.get(C.CONFIG_DAP_MODULE, C.CONFIG_DAP_KEY_ARGS)
if args ~= nil then
args = vim.split(args, "")
end
require('dap-go').setup({
delve = {
cwd = CONFIG.get(C.CONFIG_DAP_MODULE, C.CONFIG_DAP_KEY_DIR),
build_flags = CONFIG.get(C.CONFIG_DAP_MODULE, C.CONFIG_DAP_KEY_BUILD_FLAGS),
args = args
}
})
end,
})
end
return M