-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Add hooks for preLaunchTask and postDebugTask #720
Comments
I'm happy to do the work here, btw, I just want to get approval for the approach. |
I agree that some extension mechanism to handle this use-case would make sense. Do you have a proposal for the API? Another use-case I can imagine is the So I'm thinking this could either be something where extensions can register handles for specific properties, or it would be a more general pluggable config pre-processing mechanism that's global instead of per adapter. |
I would personally lean more towards a general pluggable config pre-processor. As you mentioned, adapters already have the ability to do this via the local function my_hook() end
dap.on_pre_run["overseer"] = my_hook Or since this is actually very similar to the adapter dap.enrich_config["overseer"] = my_hook I don't know if we need to worry too much about conflicting extensions or the ordering of these methods. I've seen a lot of pub/sub APIs in various systems (including vim's autocmds) with minimal or no control over ordering and that usually isn't an issue. But if you think it's something that should be possible, the API could be changed to support internals that are more list-like. local function my_hook() end
dap.add_pre_run_hook(my_hook) -- implicit ordering; first added, first called
dap.remove_pre_run_hook(my_hook) This would allow users to roughly enforce some sort of order in a pinch, and the API could easily be extended in the future to take an options table with a |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@mfussenegger do you have any comments about the API proposal above? |
This would be useful for things such as Ruby on Rail's server debugging, where after the debugging session ends, the server should be stopped. This helps avoid the need to manually stop the server, as it's hogging the port required to start another debug session: |
I would love to have an option for asynchronous tasks as well. But I guess what I'm looking for is more of a |
Made a follow up that moves Closing this for now but please let me know if you encounter any limitations with this system. |
The new API is great! I refactored my integration to use it instead of monkey patching stevearc/overseer.nvim@ecdfbac |
Nice to hear. |
Problem Statement
The launch.json file format allows specifying a
preLaunchTask
and apostDebugTask
, which will run an asynchronous job before and after the debugging session. At the moment, these values are ignored by nvim-dap, which is unfortunate because they may be a required step for making the debug session work.Possible Solutions
I have written a task-manager plugin that has support for the VS Code
tasks.json
file format, and currently have an integration for nvim-dap that wires these properties up correctly. However, it unfortunately relies on some pretty gross monkey patching. I'm proposing adding a hook fordap.run
that will, when present, call a user-defined function and pass it a callback that will resume execution when called. That would be enough for me to get rid of the monkey patching, and it's generic enough that it doesn't tie nvim-dap to overseer, or to thelaunch.json
format.There has been some prior discussion about this (#191), where the suggestion was to put the task running logic into the adapter. I believe that it makes more sense to add this to dap core instead of the adapters because the
preLaunchTask
/tasks.json
format is universal across adapters.Considered Alternatives
We could continue with the monkey patching. It's more brittle, but it does currently work in most cases.
The text was updated successfully, but these errors were encountered: