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

Add documentation for setting up debugging #1050

Open
danielrainer opened this issue Sep 9, 2022 · 5 comments
Open

Add documentation for setting up debugging #1050

danielrainer opened this issue Sep 9, 2022 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@danielrainer
Copy link
Contributor

Hi, thank you for this project!

I recently tried to get debugging to work with Vimspector. It works well now that I found out how to do it, but finding out how to set it up was quite difficult. I only managed to do it after looking into the code of this project to see how Vimspector is called when calling :CocCommand rust-analyzer.debug. It would be really nice if this project had some documentation and examples how to set up a debugger.

For reference, and because I have no better place to put it, here is how I got it to work:

relevant settings in coc-settings.json (:CocConfig):

{
  "rust-analyzer.debug.runtime": "vimspector"
}

With this setup, :CocCommand rust-analyzer.debug calls Vimspector with a dictionary containing the three keys configuration, Executable, and Args. By default configuration is set to launch (configurable with rust-analyzer.debug.vimspector.configuration.name). Executable is the file path of the Rust binary and Args the arguments passed to it.

The Vimspector plugin obviously needs to be installed. In addition, run :VimspectorInstall CodeLLDB.

Vimspector needs to be configured with a config file. It can either be in the Rust project root and called .vimspector.json or a global config file (see https://puremourning.github.io/vimspector/configuration.html#project-and-global-configurations). The config file should look like this:

{
  "$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json",
  "configurations": {
    "launch": {
      "adapter": "CodeLLDB",
      "configuration": {
        "request": "launch",
        "program": "${Executable}",
        "args": [ "*${Args}" ]
      }
    }
  }
}

The key launch must be the same as rust-analyzer.debug.vimspector.configuration.name. The values "${Executable}" and [ "*${Args}" ] are automatically replaced by the values passed in by coc-rust-analyzer.

At this point, it should be possible to run Rust executables and tests with :CocCommand rust-analyzer.debug.

@fannheyward fannheyward added the help wanted Extra attention is needed label Sep 28, 2022
@timsu92
Copy link

timsu92 commented Mar 4, 2023

Wow! Thanks a lot both of you!

@SeniorMars
Copy link
Contributor

I made a video on this some time ago: https://www.youtube.com/watch?v=U3uvbdgFMRE

Though it would be nice if documentation was provided in the readme. I've also been waiting for dap support in coc.

@timsu92
Copy link

timsu92 commented Mar 16, 2023

I would suggest you try Vimspector.

@fannheyward
Copy link
Owner

Thank you guys, to be honest I didn't use debugging in vim/nvim. You're welcome to submit a PR for setting up debugging.

@SeniorMars
Copy link
Contributor

Honestly, that's interesting! I'd like to know if you could tell us what your debugging setup looks like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants