Skip to content

Add hooks for preLaunchTask and postDebugTask #720

@stevearc

Description

@stevearc

Problem Statement

The launch.json file format allows specifying a preLaunchTask and a postDebugTask, 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 for dap.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 the launch.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions