Skip to content
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

feat(utils): Implement pick_files() #1190

Merged
merged 4 commits into from May 23, 2024

Conversation

cryptomilk
Copy link
Contributor

This implements a file picker, to pick the file you want to execute with the debugger.

Fixes #1130

@cryptomilk
Copy link
Contributor Author

It looks like this with telescope dap:

image

@cryptomilk
Copy link
Contributor Author

Ping?

@mfussenegger
Copy link
Owner

mfussenegger commented May 22, 2024

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_one is 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 find as 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 to pick_process

@cryptomilk
Copy link
Contributor Author

A fallback for nvim 0.10 would be nice as it just has been released :-)

@mfussenegger
Copy link
Owner

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.

@cryptomilk
Copy link
Contributor Author

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 :-)

@mfussenegger
Copy link
Owner

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.

@mfussenegger mfussenegger merged commit fa226c4 into mfussenegger:master May 23, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add picker for executables/files
2 participants