Skip to content

Commit

Permalink
fix: realtime settings loading
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavyPunk committed Nov 7, 2024
1 parent de14434 commit a73a02c
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions lua/neotest-golang/features/dap/init.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
--- DAP setup related functions.

local options = require("neotest-golang.options")
local dap_manual = require("neotest-golang.features.dap.dap_manual")
local dap_go = require("neotest-golang.features.dap.dap_go")

local M = {}

local dap_manual_enabled = options.get().dap_manual_enabled
if type(dap_manual_enabled) == "function" then
dap_manual_enabled = dap_manual_enabled()
local function is_dap_manual_enabled()
local dap_manual_enabled = options.get().dap_manual_enabled
if type(dap_manual_enabled) == "function" then
dap_manual_enabled = dap_manual_enabled()
end
return dap_manual_enabled
end

if dap_manual_enabled then
M = require("neotest-golang.features.dap.dap_manual")
else
M = require("neotest-golang.features.dap.dap_go")
---@param cwd string
function M.setup_debugging(cwd)
if is_dap_manual_enabled() then
dap_manual.setup_debugging(cwd)
else
dap_go.setup_debugging(cwd)
end
end

--- @param test_path string
--- @param test_name_regex string?
--- @return table | nil
function M.get_dap_config(test_path, test_name_regex)
if is_dap_manual_enabled() then
return dap_manual.get_dap_config(test_path, test_name_regex)
else
return dap_go.get_dap_config(test_path, test_name_regex)
end
end

function M.assert_dap_prerequisites()
if is_dap_manual_enabled() then
dap_manual.assert_dap_prerequisites()
else
dap_go.assert_dap_prerequisites()
end
end

return M

0 comments on commit a73a02c

Please sign in to comment.