pocco81 / dap-buddy.nvim

🐞 Debug Adapter Protocol manager for Neovim
GNU General Public License v3.0
400 stars 48 forks source link

How do I get nvim-dap to work with typescript/typescriptreact using DAPInstall? #38

Closed mawkler closed 2 years ago

mawkler commented 2 years ago

When I run continue() in a .ts/.tsx file I get the following error message: Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with your adapter or 'chrome' configuration. Check the logs for errors (:help dap.set_log_level)

I've tried to use DAPInstall's default configuration as seen below, shouldn't that be enough to get a debugger up and running?:

local dap = require('dap')
local di = require('dap-install')

di.config('chrome', {})

I've also tried merging the above DAPInstall config with nvim-dap's instructions for typescript. But I'm not sure exactly how.

What am I doing wrong?

pocco81 commented 2 years ago

Hey! So this debugger was introduced by #28.

The only problem I see in your config is that you shouldn't require nvim-dap. DAPInstall does that, so try to stick to the default config:

local dap_install = require("dap-install")
dap_install.config("chrome", {<you can pass another config to it here>})

Also, keep in mind that DAPInstall is using the default config for each debugger, so their is no need to "merge DAPInstalls' config with nvim-daps'", because they are the same.

mawkler commented 2 years ago

@Pocco81 The reason for the error message was that I had missed that I need to have chrome running with a remote debugger port like so:

google-chrome-stable --remote-debugging-port=9222

However, now when I set a breakpoint using toggle_breakpoint() and run continue() I get the following error message:

Breakpoint ignored because generated code not found (source map problem?).

I've even tried debugging the template react app created using the following command, but I still ge the same behaviour:

npx create-react-app my-app2 --template typescript

I'm guessing however that this is a problem with the debug adapter, and not with DAPInstall.

However, I have another question: how do I tell DAPInstall to use the adapter chrome for .ts files as well? I currently get the following message:

No configuration found for 'typescript'. You need to add configs to 'dap.configurations.typescript' (See ':h dap-configuration')

but I'm not quite sure how I configure this using DAPInstall.

pocco81 commented 2 years ago

Oh ok gotcha. The current config for the chrome debugger works for javascriptreact and typescriptreact (as you can see here). So yeah it's my bad for not adding typescript to that table. I'll fix it ASAP, feel free to PR the fix tho!