-
Notifications
You must be signed in to change notification settings - Fork 15
Debugging Recipes
Rónán Carrigan edited this page Aug 15, 2021
·
2 revisions
The following are some working configurations for integrating with nvim-dap. If not explicitly stated, it is assumed that the nvim-dap configuration is the one found in nvim-dap's installation wiki
For creating and using these configurations with vim-ultest, see :h ultest-debugging
.
nvim-dap config: nvim-dap-python vim-ultest config:
function(cmd)
-- The command can start with python command directly or an env manager
local non_modules = {'python', 'pipenv', 'poetry'}
-- Index of the python module to run the test.
local module_index = 1
if vim.tbl_contains(non_modules, cmd[1]) then
module_index = 3
end
local module = cmd[module_index]
-- Remaining elements are arguments to the module
local args = vim.list_slice(cmd, module_index + 1)
return {
dap = {
type = 'python',
request = 'launch',
module = module,
args = args
}
}
end
function(cmd)
local args = {}
for i = 3, #cmd - 1, 1 do
local arg = cmd[i]
if vim.startswith(arg, "-") then
-- Delve requires test flags be prefix with 'test.'
arg = "-test." .. string.sub(arg, 2)
end
args[#args + 1] = arg
end
return {
dap = {
type = "go",
request = "launch",
mode = "test",
program = "${workspaceFolder}",
dlvToolPath = vim.fn.exepath("dlv"),
args = args
},
parse_result = function(lines)
return lines[#lines] == "FAIL" and 1 or 0
end
}
end