feat(utils): Implement pick_files()
This implements a file picker, to pick the file you want to execute with the debugger.
Fixes #1130
It looks like this with telescope dap:
Ping?
Pushed a couple of changes:
- Uses vim.fs.dir instead of find/bfs to make it platform independent (but requires nvim 0.11)
- Default executables to true as I think that's the common use case and it allows to use it like
program = require("dap.utils").pick_file,in a configuration entry, without wrapping it in another function to provide the arguments. - Simplified the coroutine logic, given that
pick_oneis already coroutine aware and the callback is optional. - Fixed the filter example. It is a lua-pattern, not a glob pattern.
- Added docs to dap.txt
Open questions to me:
- Could re-add
findas fallback for nvim 0.10 and earlier. - Could change the filter from a lua pattern to a glob via
vim.glob.to_lpeg()- might be more intuitive given that it is about file paths, but could also be confusing if it is different topick_process
A fallback for nvim 0.10 would be nice as it just has been released :-)
A fallback for nvim 0.10 would be nice as it just has been released :-)
Ah, I got the numbers mixed. It requires 0.10. The fallback would make it work in 0.9 or earlier.
Ah, I got the numbers mixed. It requires 0.10. The fallback would make it work in 0.9 or earlier.
Ah, then I would argue new feature new nvim version required :-)
Decided to add in the find fallback (but left bfs out). I also changed the result to return dap.ABORT, so it doesn't attempt to start the debug session if one cancels the dialog.