-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a function to get arguements for the program as user input #629
Comments
Workaround: Currently the DAP configuration can take a function to resolve the value dynamically (but in a blocking way): Example codedap.configurations.cpp = {
...
{
name = "Launch this file with arguments",
type = "cppdbg",
request = "launch",
program = function()
return "${fileDirname}/${fileBasenameNoExtension}"
end,
args = function()
local x = vim.fn.input('Args :');
if x and x ~= "" then return vim.split(s, ' ') end -- Note: does not deal with quotes and spaces correctly
return nil
end,
cwd = '${workspaceFolder}',
},
...
} To my knowledge there is no way to resolve the configuration this asynchronously, e.g., via |
asynchronous operations are supported. See |
I see, the idea is to use a coroutine. It's very smart. So users can use An example code...
args = function()
return coroutine.create(function(dap_run_co)
vim.ui.input({ prompt = 'Args >'}, function(choice)
choice = choice or ''
local arg = vim.split(choice, ' ') -- TODO: use a function that handles quotes and spaces
coroutine.resume(dap_run_co, arg)
end)
end)
end,
... |
I'm using lua code to solve it, without a coroutine, maybe it helps you.
|
I'm not sure how to best deal with that as |
Problem Statement
The majority of debuggers require args for the program being debugged to be passed in as an array. To handle things like escape characters with \ or not splitting things between quotes as separate items in the array is a pain, so I think providing this functionality in nvim-dap itself would be useful. Obviously I could just use
vim.fn.input
and split it by spaces into an array but that's not optimal.Ideas or possible solutions
Just some function that takes a string of args as input and returns them split into an array while handling \ and quotes.
The text was updated successfully, but these errors were encountered: