|
|
|
@ -111,6 +111,18 @@ M.run = function(...)
|
|
|
|
|
request = "launch",
|
|
|
|
|
dlvToolPath = vim.fn.exepath("dlv")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
|
|
|
row, col = row, col + 1
|
|
|
|
|
|
|
|
|
|
local ns = require("go.ts.go").get_func_method_node_at_pos(row, col)
|
|
|
|
|
if ns == nil or ns == {} then
|
|
|
|
|
log('ts not not found, debug while file')
|
|
|
|
|
if mode == 'nearest' then
|
|
|
|
|
mode = 'test'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if mode == 'test' then
|
|
|
|
|
dap_cfg.name = dap_cfg.name .. ' test'
|
|
|
|
|
dap_cfg.mode = "test"
|
|
|
|
@ -119,6 +131,14 @@ M.run = function(...)
|
|
|
|
|
dap_cfg.program = "./${relativeFileDirname}"
|
|
|
|
|
dap.configurations.go = {dap_cfg}
|
|
|
|
|
dap.continue()
|
|
|
|
|
elseif mode == 'nearest' then
|
|
|
|
|
dap_cfg.name = dap_cfg.name .. ' test_nearest'
|
|
|
|
|
dap_cfg.mode = "test"
|
|
|
|
|
dap_cfg.program = "./${relativeFileDirname}"
|
|
|
|
|
dap_cfg.args = {'-test.run', '^' .. ns.name}
|
|
|
|
|
log(dap_cfg)
|
|
|
|
|
dap.configurations.go = {dap_cfg}
|
|
|
|
|
dap.continue()
|
|
|
|
|
else
|
|
|
|
|
dap_cfg.program = "${file}"
|
|
|
|
|
dap_cfg.args = args
|
|
|
|
|