2024-09-07 18:39:22 +00:00
|
|
|
local T = require('toolchain')
|
2024-09-07 23:50:39 +00:00
|
|
|
local C = require('util.const')
|
|
|
|
local CONFIG = require('util.config')
|
2024-09-07 18:39:22 +00:00
|
|
|
local M = {}
|
|
|
|
|
2024-09-07 23:50:39 +00:00
|
|
|
function M.setup()
|
2024-09-07 18:39:22 +00:00
|
|
|
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()
|
2024-09-07 23:50:39 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
})
|
2024-09-07 18:39:22 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|