feat: add debugger for Go

This commit is contained in:
Stevan Freeborn
2025-12-22 17:00:38 -06:00
parent 87547ff7af
commit 12e8b4211f
+43
View File
@@ -244,6 +244,49 @@ return {
}, },
} }
dap.adapters.delve = function(callback, config)
if config.mode == "remote" and config.request == "attach" then
callback({
type = "server",
host = config.host or "127.0.0.1",
port = config.port or "38697",
})
else
callback({
type = "server",
port = "${port}",
executable = {
command = "dlv",
args = { "dap", "-l", "127.0.0.1:${port}", "--log", "--log-output=dap" },
detached = vim.fn.has("win32") == 0,
},
})
end
end
dap.configurations.go = {
{
type = "delve",
name = "Debug",
request = "launch",
program = "${file}",
},
{
type = "delve",
name = "Debug test",
request = "launch",
mode = "test",
program = "${file}",
},
{
type = "delve",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./${relativeFileDirname}",
},
}
local codelldb_path = vim.fn.has("win32") local codelldb_path = vim.fn.has("win32")
and vim.fn.stdpath("data") .. "/mason/packages/codelldb/extension/adapter/codelldb.exe" and vim.fn.stdpath("data") .. "/mason/packages/codelldb/extension/adapter/codelldb.exe"
or vim.fn.stdpath("data") .. "/mason/packages/codelldb/extension/adapter/codelldb" or vim.fn.stdpath("data") .. "/mason/packages/codelldb/extension/adapter/codelldb"