You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VSCode provides support for a command type for inputs in launch.json files, which is similar to pickString, except a VSCode command is specified to dynamically populate the set of options in the dropdown[1]. I would like to have similar functionality with nvim-dap.
Obviously in neovim we don't have access to VSCode commands, so in order to be able to share launch.json files with VSCode users, I think the best way to do this would be to allow users to specify implementations (e.g. in lua) of VSCode commands for nvim-dap to use.
I have written a PR which allows the user to provide an (optional) additional argument command_callbacks to load_launchjs. This is a table indexed by names of VSCode commands, each providing a callback function, with the option to provide a 'default' callback in command_callbacks[1], to allow the user to handle parsing/dispatching commands themselves/hand this off to some other plugin. The callback functions are passed the name of the the command called, as well as the args section of the input from the launch.json. Callbacks should return a table with strings to appear in the dropdown.
Here is a quick-and-dirty example of how you could use this for a 'pick a unit test to run' launch configuration, in a c++/googletest project. This uses the shellCommand.execute VSCode command from [2], which lets you run a shell command by calling a VSCode command:
Example launch.json: (The command here simply gets a list of tests from gtest (i.e. TestGroup.TestName), separated by newlines)
This was something that I put together fairly quickly mostly for my own use, and I'm open to reworking it if you don't think this is the right approach (It definitely needs adding to the documentation if you agree to merge it in any case). I do think that this is a feature worth having in nvim-dap upstream in some form though, so I'd be really interested to hear what you think.
The text was updated successfully, but these errors were encountered:
I think this should now be possible using a on_config hook. See :help dap-listeners-on_config
Your hook would have to go through the configurations properties, see if there is any ${input:<id>} keys or values left, load the inputs.json and execute the commands.
Granted, this is not as easy as the proposed PR, but I think it is a fair trade-off.
I'm somewhat open to make that easier by adding a dap.providers.var_placeholder extension point, but I'd first like to see if that is really necessary.
Problem Statement
VSCode provides support for a
command
type for inputs in launch.json files, which is similar topickString
, except a VSCode command is specified to dynamically populate the set of options in the dropdown[1]. I would like to have similar functionality with nvim-dap.[1] https://code.visualstudio.com/docs/editor/variables-reference#_input-variables
Possible Solutions
Obviously in neovim we don't have access to VSCode commands, so in order to be able to share launch.json files with VSCode users, I think the best way to do this would be to allow users to specify implementations (e.g. in lua) of VSCode commands for nvim-dap to use.
I have written a PR which allows the user to provide an (optional) additional argument
command_callbacks
toload_launchjs
. This is a table indexed by names of VSCode commands, each providing a callback function, with the option to provide a 'default' callback incommand_callbacks[1]
, to allow the user to handle parsing/dispatching commands themselves/hand this off to some other plugin. The callback functions are passed the name of the the command called, as well as theargs
section of the input from the launch.json. Callbacks should return a table with strings to appear in the dropdown.Here is a quick-and-dirty example of how you could use this for a 'pick a unit test to run' launch configuration, in a c++/googletest project. This uses the
shellCommand.execute
VSCode command from [2], which lets you run a shell command by calling a VSCode command:Example launch.json: (The command here simply gets a list of tests from gtest (i.e. TestGroup.TestName), separated by newlines)
Example
command_callbacks
providing a (thrown together and feature-incomplete) implementation ofshellCommand.execute
:Running this gives you a dropdown that looks a bit like this, with each of the tests to select from:
[2] https://marketplace.visualstudio.com/items?itemName=augustocdias.tasks-shell-input
Considered Alternatives
This was something that I put together fairly quickly mostly for my own use, and I'm open to reworking it if you don't think this is the right approach (It definitely needs adding to the documentation if you agree to merge it in any case). I do think that this is a feature worth having in nvim-dap upstream in some form though, so I'd be really interested to hear what you think.
The text was updated successfully, but these errors were encountered: