Skip to content

Commit

Permalink
feat: use build flags for delve in dap-go config
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Sep 7, 2024
1 parent 8e3698a commit 2f07c72
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lua/neotest-golang/features/dap/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
--- DAP setup related functions.

local options = require("neotest-golang.options")
local logger = require("neotest-golang.logging")

local M = {}

Expand All @@ -13,10 +14,15 @@ function M.setup_debugging(cwd)
dap_go_opts.delve = {}
end
dap_go_opts.delve.cwd = cwd
logger.debug({ "Provided dap_go_opts for DAP: ", dap_go_opts })
require("dap-go").setup(dap_go_opts)

-- reset nvim-dap-go (and cwd) after debugging with nvim-dap
require("dap").listeners.after.event_terminated["neotest-golang-debug"] = function()
logger.debug({
"Resetting provided dap_go_opts for DAP: ",
dap_go_opts_original,
})
require("dap-go").setup(dap_go_opts_original)
end
end
Expand All @@ -34,6 +40,11 @@ function M.get_dap_config(test_name_regex)
args = { "-test.run", test_name_regex },
}

local dap_go_opts = options.get().dap_go_opts or {}
if dap_go_opts.delve ~= nil and dap_go_opts.delve.build_flags ~= nil then
dap_config.buildFlags = dap_go_opts.delve.build_flags
end

return dap_config
end

Expand Down

0 comments on commit 2f07c72

Please sign in to comment.