nvim-dap icon indicating copy to clipboard operation
nvim-dap copied to clipboard

feat(utils): Implement pick_files()

Open cryptomilk opened this issue 1 year ago • 2 comments

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

Fixes #1130

cryptomilk avatar Apr 14 '24 14:04 cryptomilk

It looks like this with telescope dap:

image

cryptomilk avatar Apr 14 '24 14:04 cryptomilk

Ping?

cryptomilk avatar May 04 '24 13:05 cryptomilk

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

mfussenegger avatar May 22 '24 21:05 mfussenegger

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

cryptomilk avatar May 22 '24 21:05 cryptomilk

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.

mfussenegger avatar May 22 '24 21:05 mfussenegger

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

cryptomilk avatar May 23 '24 05:05 cryptomilk

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 avatar May 23 '24 07:05 mfussenegger