-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |