coc-rust-analyzer

June 13, 2026 ยท View on GitHub

GitHub Sponsors Patreon donate button PayPal donate button

rust-analyzer for Vim/Neovim, works as an extension with coc.nvim.

10

Install

:CocInstall coc-rust-analyzer

remove rust-analyzer config from coc-settings.json if you've set

Notes

It's recommended to add $CARGO_HOME to workspace.ignoredFolders to stop rust-analyzer runs cargo check on sysroot crates:

"workspace.ignoredFolders": [
  "$HOME",
  "$HOME/.cargo/**",
  "$HOME/.rustup/**"
],

Configurations

This extension is configured using a jsonc file. You can open this configuration file using the command :CocConfig, and it is typically located at $HOME/.config/nvim/coc-settings.json. You can get the configurations list from the package.json file of this extension.

Commands

You can use these commands by :CocCommand XYZ.

CommandDescription
rust-analyzer.analyzerStatusShow rust-analyzer status
rust-analyzer.debugList available runnables of current file and debug the selected one
rust-analyzer.expandMacroExpand macro recursively
rust-analyzer.explainErrorExplain the currently hovered error message
rust-analyzer.joinLinesJoin lines
rust-analyzer.matchingBraceFind matching brace
rust-analyzer.memoryUsageMemory Usage (Clears Database)
rust-analyzer.moveItemUpMove item up
rust-analyzer.moveItemDownMove item down
rust-analyzer.openDocsOpen docs under cursor
rust-analyzer.parentModuleLocate parent module
rust-analyzer.peekTestsPeek related tests
rust-analyzer.reloadRestart rust-analyzer server
rust-analyzer.reloadWorkspaceReload workspace
rust-analyzer.runList available runnables of current file and run the selected one
rust-analyzer.serverVersionShow current Rust Analyzer server version
rust-analyzer.ssrStructural Search Replace
rust-analyzer.viewSyntaxTreeShow syntax tree
rust-analyzer.testCurrentTest Current
rust-analyzer.installInstall latest rust-analyzer from GitHub release
rust-analyzer.upgradeDownload latest rust-analyzer from GitHub release
rust-analyzer.viewHirView Hir
rust-analyzer.viewMirView Mir
rust-analyzer.viewFileTextView File Text
rust-analyzer.viewCrateGraphView Crate Graph
rust-analyzer.viewFullCrateGraphView Crate Graph (Full)
rust-analyzer.shuffleCrateGraphShuffle Crate Graph
rust-analyzer.runFlycheckRun flycheck
rust-analyzer.cancelFlycheckCancel running flychecks
rust-analyzer.clearFlycheckClear flycheck diagnostics
rust-analyzer.rebuildProcMacrosRebuild proc macros and build scripts
rust-analyzer.interpretFunctionInterpret Function

Debugging with Vimspector

To debug Rust runnables with Vimspector, set the debug runtime in coc-settings.json:

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

Install Vimspector and the CodeLLDB adapter with :VimspectorInstall CodeLLDB. Then add a Vimspector configuration, either in the project root as .vimspector.json or in a global Vimspector configuration file:

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

The launch key must match rust-analyzer.debug.vimspector.configuration.name, which defaults to launch. :CocCommand rust-analyzer.debug passes Executable and Args to Vimspector for the selected runnable.

License

MIT


This extension is built with create-coc-extension