CLI arguments in dap.continue() #1047
-
|
I want to debug a program that takes cli arguments. I see that this is possible using run, but run doesn't search for the current file's configuration, and continue doesn't take any options. So is there a clean way of doing this? vim.keymap.set("n", "<leader>dq", function()
local args = vim.fn.input("Cli arguments: ")
require("dap").continue({
args = args,
})
end, { noremap = true })#597 (comment) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If you really want to add the same args to all configurations, it's just a bit of lua: local dap = require("dap")
for ft, configs in pairs(dap.configurations) do
for _, config in ipairs(configs) do
config.args = args
end
endThe usual approach is to have one dedicated configuration that prompts for args. For example: {
type = 'python';
request = 'launch';
name = 'Launch file with arguments';
program = '${file}';
args = function()
local args_string = vim.fn.input('Arguments: ')
return vim.split(args_string, " +")
end;
} |
Beta Was this translation helpful? Give feedback.
-
|
Mmmh, one thing though, maybe this is a bug: When running a config, terminating and then running run_last, it will run that previous config without reprompting arguments. However, if you then run terminate and run continue then terminate and then run_last it will reprompt every time.
|
Beta Was this translation helpful? Give feedback.
If you really want to add the same args to all configurations, it's just a bit of lua:
The usual approach is to have one dedicated configuration that prompts for args. For example:
{ type = 'python'; request = 'launch'; name = 'Launch file with arguments'; program = '${file}'; args = function() local args_string = vim.fn.input('Arguments: ') return vim.split(args_string, " +") end; }