Add picker for executables/files
Problem Statement
You provide a nice picker to select a process to get the pid. It would be great to have the same available to select programs/executables to debug.
I'm currently using:
program = function()
local path = vim.fn.input({
prompt = 'Path to executable: ',
default = vim.fn.getcwd() .. '/',
completion = 'file',
})
return (path and path ~= '') and path or dap.ABORT
end,
args = function()
local args_str = vim.fn.input({
prompt = 'Arguments: ',
})
return vim.split(args_str, ' +')
end,
Possible Solutions
It would be nice if you would have a picker searching for executables in the directory.
program = require('dap.utils').pick_file({ executables_only = true })
It could also be used maybe with a filter:
program = require('dap.utils').pick_file({ filter = '*.py' })
Considered Alternatives
No response
I have a first implementation here: https://git.cryptomilk.org/users/asn/dotfiles.git/tree/dot_config/nvim/lua/plugins/dap/c.lua#n51
I just noticed that you removed the search_path option. The Samba project has a lot of files (~50k), I don't really want to search for executables in the whole source tree, I only want to search for them in the build directory. That's why I added an option to specify it.
local cwd = vim.fn.getcwd()
local is_samba = cwd:find('samba')
local path = nil
if is_samba then
path = cwd .. '/bin'
end
opts {
path = path,
}
Created https://github.com/mfussenegger/nvim-dap/pull/1218