Closed liquiddandruff closed 1 year ago
Found it! :) From https://github.com/mfussenegger/nvim-dap/issues/20#issuecomment-1212214935
See :help dap.ext.vscode.load_launchjs
For the above configuration, calling load_launchjs adds the first entry to dap.configurations.java and the second entry to dap.configurations.cppdbg. If you wanted to add the second entry to the c or cpp configurations you could call load_launchjs like this instead:
require('dap.ext.vscode').load_launchjs(nil, { cppdbg = {'c', 'cpp'} })
So all we need is to remap the rt_lldb
type to rust
like so:
require('dap.ext.vscode').load_launchjs(nil, {rt_lldb= {'rust'} })
Ensure your cwd has '.vscode/launch.json' in path (if the path is nil, load_launchjs defaults to this).
Then pressing F5 starts a debugging session and everything works.
My full .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "rt_lldb",
"request": "launch",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}",
"stopAtEntry": true
}
]
}
I created a page to document this at https://github.com/simrat39/rust-tools.nvim/wiki/Use-with-dap.ext.vscode-launch.json
I can set a breakpoint via
require'dap'.toggle_breakpoint()
, and:RustDebuggables
behaves as expected: my breakpoint gets hit and the other dap commands likerequire'dap'.continue()
work.However once my session is finished, I often hit F5 again to start another debugging session (I have it bound via
vim.keymap.set('n', '<F5>', require 'dap'.continue)
which I use in other languages).I tried getting something to work via:
.vscode/launch.json
but
dap
doesn't recognize this configuration. Pressing F5 results in:No configuration found for `rust`. You need to add configs to `dap.configurations.rust` (See `:h dap-configuration`)
If instead I change the type from
rt_lldb
torust
, then of course I getThe selected configuration references adapter `rust`, but dap.adapters.rust is undefined
sincert_lldb
is the adapter called via:RustDebuggables
.So my question is, is there a way to get
dap
to use thert_lldb
adapter automatically? Maybe I should define dap.adapters.rust myself and make it call intort_lldb
somehow? But I'm not sure how to do that, or if that's the best way.Any help on this would be appreciated, thank you!