How do I Start Debugging from a module file? #289
-
|
I'm pretty new to neovim and rust, so if I'm asking in the wrong place and you think this is a question for rust-analyzer (or even just rust/cargo in general) just let me know! Thanks in advance for your help <3 I installed codelldb manually and use Lazy to install rustaceanvim, nvim-dap, and nvim-dapui, and when I run For context, here is what the relevant parts of my files look like:
and when I run and finally I thought that maybe I needed to tell cargo about the build explicitly so that rust-analyzer would pick it up even if I was in a different file, but when I add the below to It's also possible I'm misconfiguring something, so here are the relevant parts of my If I'm configuring something incorrectly or non-idiomatically please let me know. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
|
Oh and in case it matters, my neovim version and |
Beta Was this translation helpful? Give feedback.
-
|
Hey 👋
However, rustaceanvim will by default run the command whenever you open a module, and register them with nvim-dap. I don't think it's likely that rust-analyzer will implement the feature as you describe it, because it could But rustaceanvim does support loading project-specific debug configurations using Regarging your config: I can't see anything wrong with it. You shouldn't need to configure |
Beta Was this translation helpful? Give feedback.
-
|
Oh if I remove the dap configuration, when I run I added the manual configuration because I thought that rustaceanvim wasn't configuring dap. Now that I've removed the manual dap configuration I can see that rustaceanvim does configure dap, but only if I open After further testing, I learned that if I add a simple test to (I understand that rustaceanvim has to wait for rust-analyzer to initialize before it configures dap, but in this case even if I wait for a very long time it never configures dap whereas it normally only takes like, one second. So I think it's actually just not configuring in this case, although if there's a way to double check whether or not rust-analyzer is still actively working I'd be happy to check whether or not that's the case here. I took a look using htop and it doesn't look like rust-analyzer is doing anything different after the first second or two regardless of if I have the test in |
Beta Was this translation helpful? Give feedback.
-
Could you please point me to a file in a cargo project in a GitHub repo or gist that I can use to try this out? 🤔 Maybe rustaceanvim is adding the configuration, but nvim-dap isn't picking it up?
Yes. It wouldn't make sense to try to debug things that can't be debugged.
Rustaceanvim doesn't provide a function as part of its public API (i.e. if you use it, I can't guarantee you that it won't be moved, renamed, or change its signature between minor version bumps).
That's because You can also use vim.keymap.set("n", "<leader>dc", function()
-- will fail if there is no rust-analyzer client
local success = pcall(vim.cmd.RustLsp, "debuggables")
if not success then
vim.cmd.DapContinue()
end
end) |
Beta Was this translation helpful? Give feedback.
Okay so after some playing around I realized that this only happens if there is another binary. I set up an simple example cargo project at https://github.com/l3france/rustaceanvim-dap-configuration
Dap does not get configured when I open
src/my_mod.rsin that project, but if you removesrc/bin/other.rs(and it's reference in Cargo.toml) then it does get configured. At first I thought that maybe rust-analyzer was getting confused and couldn't select a binary to build. But even if I add Cargo.toml entries for the two binaries it doesn't work. It's very possible I'm configuring the project wrong in Cargo.toml and that's why it's breaking, I'm new to cargo.I also found that even if dap is c…