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

Auto Attach is possible? #978

Closed
andresgutgon opened this issue Jun 26, 2023 · 2 comments
Closed

Auto Attach is possible? #978

andresgutgon opened this issue Jun 26, 2023 · 2 comments

Comments

@andresgutgon
Copy link

Problem Statement

Hi, I've been configuring my nvim to debug on my editor a next.js app. And it works by starting a dev server with node options for debugging like this:

NODE_OPTIONS='--inspect' pnpm dev

But I was wondering if it's possible to launch a next server from nvim like VSCode does.
This is my launch.json in VSCode

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Next.js: (node-terminal)",
      "type": "node-terminal",
      "request": "launch",
      "command": "pnpm dev"
    }
  ]
}

This starts the server inside VSCode and the debugger is up and running
image

So you this would be possible use nvim-dap?

Thanks for this awesome project!

Possible Solutions

No idea.

Considered Alternatives

The alternative is to use NODE_OPTIONS in a terminal and then attach to that next server. Is fine but it would be awesome to be able to launch the server and attach within nvim.

@mfussenegger
Copy link
Owner

mfussenegger commented Jun 30, 2023

It looks like vscode-js-debug has client-side code that takes care of handling the command property:

https://github.com/microsoft/vscode-js-debug/blob/7fe038e4bb338f0dd2b9362a1265b1efa9b20cfc/src/targets/node/terminalNodeLauncher.ts#L145-L150

If I read that right, it won't work out of the box with nvim-dap, and is also out of scope. I suspect it could be implemented in a way in the debug-adapter that works with a regular DAP client, without the need for custom extensions, but that would need to change in vscode-js-debug. Maybe worth creating an issue in their repository.

That said, the customization & extension points of nvim-dap should be powerful enough to also implement it on the client side.

E.g. you could try using the enrich_config routine of a :h dap-adapter to spawn the command, and rewrite the configuration to attach.

This might be something to implement in https://github.com/mxsdev/nvim-dap-vscode-js

@mfussenegger mfussenegger closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2023
@andresgutgon
Copy link
Author

Thanks for the response @mfussenegger! I'll port the issue to the nvim-vscode-js repo

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

No branches or pull requests

2 participants