mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.09k stars 179 forks source link

Add ability to specify what adapter a type corresponds to from launch.json #1232

Closed jonathan-elize closed 1 month ago

jonathan-elize commented 1 month ago

I use nvim-dap-vscode-js to debug javascript and typescript files. It sets up adapters automatically with various names such as pwa-node.

In launch.json files, the "type" that is put for debugging javascript and typescript files I've found to usually be set to "node". Since right now the type is used to find the adapter by name in nvim-dap, trying to debug using these configs is failing by default since I don't have an adapter named "node". I'm creating this PR to be able to map type from the launch.json configuration to the adapter you would want to use in Neovim.

In my case, with this change I can now do this to load debug options from launch.json and run them successfully.

  local vs_map = { node = { "javascript", "typescript" } }
  local adapter_map = { node = "pwa-node" }
  require("dap.ext.vscode").load_launchjs(nil, vs_map, adapter_map)
mfussenegger commented 1 month ago

Thanks for the PR but there is already a solution for this. See https://github.com/mfussenegger/nvim-dap/issues/1104#issuecomment-1835734572

I'm also thinking of always loading launch.json implicitly when starting a debug session and drop the filetype-type mapping part. Having more config options for it would counter that plan. See https://github.com/mfussenegger/nvim-dap/issues/1226 for details