{"id":13409760,"url":"https://github.com/mrcjkb/rustaceanvim","last_synced_at":"2026-02-16T12:28:20.378Z","repository":{"id":136454760,"uuid":"366281389","full_name":"mrcjkb/rustaceanvim","owner":"mrcjkb","description":"🦀 Supercharge your Rust experience in Neovim! A heavily modified fork of rust-tools.nvim","archived":false,"fork":false,"pushed_at":"2025-05-11T00:24:39.000Z","size":1390,"stargazers_count":2291,"open_issues_count":17,"forks_count":98,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-11T01:21:04.239Z","etag":null,"topics":["dap","debug-adapter-protocol","language-server-protocol","lsp","neovim","nvim","plugin","rust","rust-analyzer","rust-lang","rust-tools"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"simrat39/rust-tools.nvim","license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrcjkb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"mrcjkb","custom":["https://paypal.me/simrat39","https://www.buymeacoffee.com/simrat39"]}},"created_at":"2021-05-11T06:39:38.000Z","updated_at":"2025-05-11T00:24:43.000Z","dependencies_parsed_at":"2023-12-31T01:29:39.330Z","dependency_job_id":"cc6b9a25-8328-47df-b06a-9e0b4db61730","html_url":"https://github.com/mrcjkb/rustaceanvim","commit_stats":{"total_commits":869,"total_committers":94,"mean_commits":9.24468085106383,"dds":0.5845799769850403,"last_synced_commit":"6eb1c41463a0ad02a4fe799321cc7f651b87e576"},"previous_names":["mrcjkb/rustaceanvim"],"tags_count":197,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrcjkb%2Frustaceanvim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrcjkb%2Frustaceanvim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrcjkb%2Frustaceanvim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrcjkb%2Frustaceanvim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrcjkb","download_url":"https://codeload.github.com/mrcjkb/rustaceanvim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059511,"owners_count":22007769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dap","debug-adapter-protocol","language-server-protocol","lsp","neovim","nvim","plugin","rust","rust-analyzer","rust-lang","rust-tools"],"created_at":"2024-07-30T20:01:03.239Z","updated_at":"2026-02-16T12:28:20.357Z","avatar_url":"https://github.com/mrcjkb.png","language":"Lua","readme":"\u003c!-- markdownlint-disable --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/mrcjkb/rustaceanvim\"\u003e\n    \u003cimg src=\"./rustaceanvim.svg\" alt=\"rustaceanvim\"\u003e\n  \u003c/a\u003e\n  \u003cp align=\"center\"\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"./doc/rustaceanvim.txt\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/mrcjkb/rustaceanvim/issues/new?assignees=\u0026labels=bug\u0026projects=\u0026template=bug_report.yml\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/mrcjkb/rustaceanvim/discussions/new?category=ideas\"\u003eRequest Feature\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/mrcjkb/rustaceanvim/discussions/new?category=q-a\"\u003eAsk Question\u003c/a\u003e\n  \u003c/p\u003e\n  \u003cp\u003e\n    \u003cstrong\u003e\n      Supercharge your Rust experience in \u003ca href=\"https://neovim.io/\"\u003eNeovim\u003c/a\u003e!\u003cbr /\u003e\n      A heavily modified fork of \u003ca href=\"https://github.com/simrat39/rust-tools.nvim\"\u003erust-tools.nvim\u003c/a\u003e\u003cbr /\u003e\n    \u003c/strong\u003e\n  \u003c/p\u003e\n  \u003cp\u003e🦀\u003c/p\u003e\n\n[![Neovim][neovim-shield]][neovim-url]\n[![Lua][lua-shield]][lua-url]\n[![Rust][rust-shield]][rust-url]\n[![Nix][nix-shield]][nix-url]\n\n[![GPL2 License][license-shield]][license-url]\n[![Issues][issues-shield]][issues-url]\n[![Build Status][ci-shield]][ci-url]\n[![LuaRocks][luarocks-shield]][luarocks-url]\n\u003c/div\u003e\n\u003c!-- markdownlint-restore --\u003e\n\n\u003e [!NOTE]\n\u003e\n\u003e - Just works. [No need to call `setup`!](https://mrcjkb.dev/posts/2023-08-22-setup.html)\n\u003e - No dependency on `lspconfig`.\n\u003e - Lazy initialization by design.\n\n## :link: Quick Links\n\n- [:pencil: Prerequisites](#pencil-prerequisites)\n- [:inbox_tray: Installation](#inbox_tray-installation)\n- [:zap: Quick setup](#zap-quick-setup)\n- [:books: Usage / Features](#books-usage--features)\n- [:gear: Advanced configuration](#gear-advanced-configuration)\n- [:stethoscope: Troubleshooting](#stethoscope-troubleshooting)\n- [:left_speech_bubble: FAQ](#left_speech_bubble-faq)\n- [:rowboat: Migrating from rust-tools](https://github.com/mrcjkb/rustaceanvim/discussions/122)\n\n## :grey_question: Do I need rustaceanvim\n\nIf you are starting out with Rust, Neovim's built-in LSP client API\n(see [`:h lsp`](https://neovim.io/doc/user/lsp.html)) or\n[`nvim-lspconfig.rust_analyzer`](https://github.com/neovim/nvim-lspconfig)\nis probably enough for you.\nIt provides the lowest common denominator of LSP support.\nThis plugin is for those who would like [additional non-standard features](#books-usage--features)\nthat are specific to rust-analyzer.\n\n## :pencil: Prerequisites\n\n### Required\n\n- `neovim \u003e= 0.11`\n- [`rust-analyzer`](https://rust-analyzer.github.io/)\n\n\u003e [!NOTE]\n\u003e\n\u003e For versions that are compatible with older Neovim versions,\n\u003e see previous major version bumps in [the changelog](./CHANGELOG.md).\n\n### Optional\n\n- [`dot` from `graphviz`](https://graphviz.org/doc/info/lang.html),\n  for crate graphs.\n- [`cargo`](https://doc.rust-lang.org/cargo/),\n  required for Cargo projects.\n- A debug adapter (e.g. [`lldb`](https://lldb.llvm.org/)\n  or [`codelldb`](https://github.com/vadimcn/codelldb))\n  and [`nvim-dap`](https://github.com/mfussenegger/nvim-dap),\n  required for debugging.\n- A tree-sitter parser for Rust (required for the `:Rustc unpretty` command).\n  Can be installed using [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter),\n  which also provides highlights, etc.\n\n## :inbox_tray: Installation\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/lua%3Arustaceanvim.svg?exclude_unsupported=1)](https://repology.org/project/lua%3Arustaceanvim/versions)\n\n### [`rocks.nvim`](https://github.com/nvim-neorocks/rocks.nvim)\n\n```vim\n:Rocks install rustaceanvim\n```\n\n### [`lazy.nvim`](https://github.com/folke/lazy.nvim)\n\n```lua\n{\n  'mrcjkb/rustaceanvim',\n  version = '^8', -- Recommended\n  lazy = false, -- This plugin is already lazy\n}\n```\n\n\u003e[!TIP]\n\u003e\n\u003eIt is suggested to pin to tagged releases if you would like to avoid breaking changes.\n\nTo manually generate documentation, use `:helptags ALL`.\n\n### Nix\n\nFor Nix users with flakes enabled, this project provides outputs in the\nform of a package and an overlay.\nIt is also available in `nixpkgs`.\n\nLook at the configuration information below to get started.\n\n## :zap: Quick Setup\n\nThis plugin automatically configures the `rust-analyzer` builtin LSP\nclient and integrates with other Rust tools.\nSee the [Usage / Features](#books-usage--features) section for more info.\n\n\u003e[!WARNING]\n\u003e\n\u003e Do not call the [`nvim-lspconfig.rust_analyzer`](https://github.com/neovim/nvim-lspconfig)\n\u003e setup or set up the LSP client for `rust-analyzer` manually,\n\u003e as doing so may cause conflicts.\n\nThis is a filetype plugin that works out of the box,\nso there is no need to call a `setup` function or configure anything\nto get this plugin working.\n\nYou will most likely want to add some keymaps.\nMost keymaps are only useful in rust files,\nso I suggest you define them in `~/.config/nvim/after/ftplugin/rust.lua`[^1]\n\n[^1]: See [`:help base-directories`](https://neovim.io/doc/user/starting.html#base-directories)\n\nExample:\n\n```lua\nlocal bufnr = vim.api.nvim_get_current_buf()\nvim.keymap.set(\n  \"n\",\n  \"\u003cleader\u003ea\",\n  function()\n    vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping\n    -- or vim.lsp.buf.codeAction() if you don't want grouping.\n  end,\n  { silent = true, buffer = bufnr }\n)\nvim.keymap.set(\n  \"n\",\n  \"K\",  -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions\n  function()\n    vim.cmd.RustLsp({'hover', 'actions'})\n  end,\n  { silent = true, buffer = bufnr }\n)\n```\n\n\u003e[!TIP]\n\u003e\n\u003e - For more LSP related keymaps, [see the `nvim-lspconfig` suggestions](https://github.com/neovim/nvim-lspconfig#suggested-configuration).\n\u003e - If you want to share keymaps with `nvim-lspconfig`,\n\u003e   you can also use the `vim.g.rustaceanvim.server.on_attach` function,\n\u003e   or an `LspAttach` autocommand.\n\u003e - See the [Advanced configuration](#gear-advanced-configuration) section\n\u003e   or `:h rustaceanvim.config` for more configuration options.\n\u003c!-- markdownlint-disable --\u003e\n\u003c!-- markdownlint-restore --\u003e\n\u003e[!IMPORTANT]\n\u003e\n\u003e - Do **not** set `vim.g.rustaceanvim`\n\u003e   in `after/ftplugin/rust.lua`, as\n\u003e   the file is sourced after the plugin\n\u003e   is initialized.\n\n## :books: Usage / Features\n\n\u003c!-- markdownlint-disable --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eDebugging\u003c/b\u003e\n  \u003c/summary\u003e\n\n  - `debuggables` opens a prompt to select from available targets.\n  - `debug` searches for a target at the current cursor position.\n\n\n  ```vim\n  :RustLsp[!] debuggables {args[]}?\n  :RustLsp[!] debug {args[]}?\n  ```\n  ```lua\n  vim.cmd.RustLsp('debug')\n  vim.cmd.RustLsp('debuggables')\n  -- or, to run the previous debuggable:\n  vim.cmd.RustLsp { 'debuggables', bang = true }\n  -- or, to override the executable's args:\n  vim.cmd.RustLsp {'debuggables', 'arg1', 'arg2' }\n  ```\n\n  Calling the command with a bang `!` will rerun the last debuggable.\n\n  Requires:\n\n  - [`nvim-dap`](https://github.com/mfussenegger/nvim-dap)\n    (Please read the plugin's documentation).\n  - A debug adapter (e.g. [`lldb-dap`](https://lldb.llvm.org/resources/lldbdap)\n    or [`codelldb`](https://github.com/vadimcn/codelldb)).\n\n  By default, this plugin will silently attempt to autoload `nvim-dap`\n  configurations when the LSP client attaches.\n  You can call them with `require('dap').continue()` or `:DapContinue` once\n  they have been loaded. The feature can be disabled by setting\n  `vim.g.rustaceanvim.dap.autoload_configurations = false`.\n\n  - `:RustLsp debuggables` will only load debug configurations\n    created by `rust-analyzer`.\n  - `require('dap').continue()` will load all Rust debug configurations,\n    including those specified in a `.vscode/launch.json`\n    (see [`:h dap-launch.json`](https://github.com/mfussenegger/nvim-dap/blob/9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5/doc/dap.txt#L316)).\n  - Note that rustaceanvim may only be able to load DAP configurations\n    when rust-analyzer has finished initializing (which may be after\n    the client attaches, in large projects). This means that the\n    DAP configurations may not be loaded immediately upon startup.\n\n  ![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/ce17d228-ae0a-416a-8159-fe095a85dcb7)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eRunnables\u003c/b\u003e\n  \u003c/summary\u003e\n\n  - `runnables` opens a prompt to select from available targets.\n  - `run` searches for a target at the current cursor position.\n\n  ```vim\n  :RustLsp[!] runnables {args[]}?\n  :RustLsp[!] run {args[]}?\n  ```\n  ```lua\n  vim.cmd.RustLsp('run')\n  vim.cmd.RustLsp('runnables')\n  -- or, to run the previous runnable:\n  vim.cmd.RustLsp { 'runnables', bang = true }\n  -- or, to override the executable's args:\n  vim.cmd.RustLsp {'runnables', 'arg1', 'arg2' }\n  ```\n\n  Calling the command with a bang `!` will rerun the last runnable.\n\n  ![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/95183192-5669-4a07-804b-83f67831be57)\n\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eTestables and failed test diagnostics\u003c/b\u003e\n  \u003c/summary\u003e\n\n  If you set the `vim.g.rustaceanvim.tools.test_executor` option to `'background'`,\n  this plugin will run tests in the background, parse the results,\n  and - if possible - display failed tests as diagnostics.\n\n  ```vim\n  :RustLsp[!] testables {args[]}?\n  ```\n  ```lua\n  vim.cmd.RustLsp('testables')\n  -- or, to run the previous testables:\n  vim.cmd.RustLsp { 'testables', bang = true }\n  -- or, to override the executable's args:\n  vim.cmd.RustLsp {'testables', 'arg1', 'arg2' }\n  ```\n\n  Calling the command with a bang `!` will rerun the last testable.\n\n  ![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/b3639b7a-105e-49de-9bdc-9c88e8e508a2)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eNeotest integration\u003c/b\u003e\n  \u003c/summary\u003e\n\n  This plugin provides a [neotest](https://github.com/nvim-neotest/neotest) adapter,\n  which you can add to neotest as follows:\n\n  ```lua\n  require('neotest').setup {\n      -- ...,\n      adapters = {\n        -- ...,\n        require('rustaceanvim.neotest')\n      },\n  }\n  ```\n\n  Note: If you use rustaceanvim's neotest adapter,\n  do not add [neotest-rust](https://github.com/rouge8/neotest-rust).\n\n  Here is a comparison between rustaceanvim's adapter and neotest-rust:\n\n  |  | rustaceanvim | neotest-rust |\n  |:--|:--|:--|\n  | Test discovery | rust-analyzer (LSP) | tree-sitter |\n  | Command construction | rust-analyzer (LSP) | tree-sitter |\n  | DAP strategy | Automatic DAP detection (reuses `debuggables`); overridable with `vim.g.rustaceanvim.dap` | Defaults to `codelldb`; manual configuration |\n  | Test runner | `cargo` or `cargo-nextest`, if detected | `cargo-nextest` |\n\n  If you configure rustaceanvim to use neotest, the `tools.test_executor`\n  will default to using neotest for `testables` and `runnables` that are tests.\n\n  ![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/b734fdb6-3c8a-492b-9b39-bb238d7cd7b1)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eExpand macros recursively\u003c/b\u003e\n  \u003c/summary\u003e\n\n  ```vim\n  :RustLsp expandMacro\n  ```\n  ```lua\n  vim.cmd.RustLsp('expandMacro')\n  ```\n  ![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/477d9e58-74b0-42ff-87ca-2fef34d06db3)\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eRebuild proc macros\u003c/b\u003e\n  \u003c/summary\u003e\n\n  ```vim\n  :RustLsp rebuildProcMacros\n  ```\n  ```lua\n  vim.cmd.RustLsp('rebuildProcMacros')\n  ```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eMove item up/down\u003c/b\u003e\n  \u003c/summary\u003e\n\n  ```vim\n  :RustLsp moveItem {up|down}\n  ```\n  ```lua\n  vim.cmd.RustLsp { 'moveItem',  'up' }\n  vim.cmd.RustLsp { 'moveItem',  'down' }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eGrouped code actions\u003c/b\u003e\n  \u003c/summary\u003e\n\n Sometimes, rust-analyzer groups code actions by category,\n which is not supported by Neovim's built-in `vim.lsp.buf.codeAction`.\n This plugin provides a command with a UI that does:\n\n ```vim\n :RustLsp codeAction\n ```\n ```lua\n vim.cmd.RustLsp('codeAction')\n ```\n\n If you set the option `vim.g.rustaceanvim.tools.code_actions.ui_select_fallback`\n to `true` (defaults to `false`), it will fall back to `vim.ui.select`\n if there are no grouped code actions.\n\n![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/866d3cb1-8e56-4380-8c03-812386441f47)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eHover actions\u003c/b\u003e\n  \u003c/summary\u003e\n\n Note: To activate hover actions, run the command twice.\n This will move you into the window, then press enter on the selection you want.\n Alternatively, you can set `auto_focus` to `true` in your config and you will\n automatically enter the hover actions window.\n\n ```vim\n :RustLsp hover actions\n ```\n ```lua\n vim.cmd.RustLsp { 'hover', 'actions' }\n ```\n\n You can invoke a hover action by switching to the hover window and entering `\u003cCR\u003e`\n on the respective line, or with a keymap for the `\u003cPlug\u003eRustHoverAction` mapping,\n which accepts a `\u003ccount\u003e` prefix as the (1-based) index of the hover action to invoke.\n\n For example, if you set the following keymap:\n\n ```lua\n vim.keymap.set('n', '\u003cspace\u003ea', '\u003cPlug\u003eRustHoverAction')\n ```\n\n you can invoke the third hover action with `3\u003cspace\u003ea`.\n\n![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/c7b6c730-4439-47b0-9a75-7ea4e6831f7a)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eHover range\u003c/b\u003e\n  \u003c/summary\u003e\n\n  ```vim\n  :RustLsp hover range\n  ```\n  ```lua\n  vim.cmd.RustLsp { 'hover', 'range' }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eExplain errors\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Display a hover window with explanations from the [rust error codes index](https://doc.rust-lang.org/error_codes/error-index.html)\n  over error diagnostics (if they have an error code).\n\n  ```vim\n  :RustLsp explainError {cycle?|cycle_prev?|current?}\n  ```\n  ```lua\n  vim.cmd.RustLsp('explainError') -- default to 'cycle'\n  vim.cmd.RustLsp({ 'explainError', 'cycle' })\n  vim.cmd.RustLsp({ 'explainError', 'cycle_prev' })\n  vim.cmd.RustLsp({ 'explainError', 'current' })\n  ```\n\n  - If called with `cycle` or no args:\n    Like `vim.diagnostic.goto_next`,\n    `explainError` will cycle diagnostics,\n    starting at the cursor position,\n    until it can find a diagnostic with an error code.\n\n  - If called with `cycle_prev`:\n    Like `vim.diagnostic.goto_prev`,\n    searches backwards for a diagnostic with an error code.\n\n  - If called with `current`:\n    Searches for diagnostics only in the\n    current cursor line.\n\n![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/bac9b31c-22ca-40c4-bfd3-b8c5ba4cc49a)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eRender diagnostics\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Display a hover window with the rendered diagnostic, as displayed\n  during `cargo build`.\n  Useful for solving bugs around borrowing and generics,\n  as it consolidates the important bits (sometimes across files)\n  together.\n\n  ```vim\n  :RustLsp renderDiagnostic {cycle?|cycle_prev?|current?}\n  ```\n  ```lua\n  vim.cmd.RustLsp('renderDiagnostic') -- defaults to 'cycle'\n  vim.cmd.RustLsp({ 'renderDiagnostic', 'cycle' })\n  vim.cmd.RustLsp({ 'renderDiagnostic', 'cycle_prev' })\n  vim.cmd.RustLsp({ 'renderDiagnostic', 'current' })\n  ```\n\n  - If called with `cycle` or no args:\n    Like `vim.diagnostic.goto_next`,\n    `renderDiagnostic` will cycle diagnostics,\n    starting at the cursor position,\n    until it can find a diagnostic with rendered data.\n\n  - If called with `cycle_prev`:\n    Like `vim.diagnostic.goto_prev`,\n    searches backwards for a diagnostic with rendered data.\n\n  - If called with `current`:\n    Searches for diagnostics only in the\n    current cursor line.\n\n![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/a972c6b6-c504-4c2a-8380-53451bb8c2de)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eJump to related diagnostics\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Sometimes, rust-analyzer provides related diagnostics in multiple locations.\n  Using the `relatedDiagnostics` subcommand, you can navigate between them.\n  If a diagnostic has more than one related diagnostic, this will populate the quickfix list.\n\n  ```vim\n  :RustLsp relatedDiagnostics\n  ```\n  ```lua\n  vim.cmd.RustLsp('relatedDiagnostics')\n  ```\n\n![](https://github.com/user-attachments/assets/26695f41-2d9d-4250-82fa-fea867fd9432)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eRelated tests\u003c/b\u003e\n  \u003c/summary\u003e\n\nQuery rust-analyzer for tests associated with the symbol under\nthe cursor (or its enclosing function) and quickly jump to one.\n\n```vim\n:RustLsp relatedTests\n```\n\n```lua\nvim.cmd.RustLsp('relatedTests')\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eOpen Cargo.toml\u003c/b\u003e\n  \u003c/summary\u003e\n\n  ```vim\n  :RustLsp openCargo\n  ```\n  ```lua\n  vim.cmd.RustLsp('openCargo')\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eOpen docs.rs documentation\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Open docs.rs documentation for the symbol under the cursor.\n\n  ```vim\n  :RustLsp openDocs\n  ```\n  ```lua\n  vim.cmd.RustLsp('openDocs')\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eParent Module\u003c/b\u003e\n  \u003c/summary\u003e\n\n  ```vim\n  :RustLsp parentModule\n  ```\n  ```lua\n  vim.cmd.RustLsp('parentModule')\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eFiltered workspace symbol searches\u003c/b\u003e\n  \u003c/summary\u003e\n\n  rust-analyzer supports filtering workspace symbol searches.\n\n  ```vim\n  :RustLsp[!] workspaceSymbol {onlyTypes?|allSymbols?} {query?}\n  ```\n  ```lua\n  vim.cmd.RustLsp('workspaceSymbol')\n  -- or\n  vim.cmd.RustLsp {\n    'workspaceSymbol',\n    '\u003conlyTypes|allSymbols\u003e' --[[ optional ]],\n    '\u003cquery\u003e' --[[ optional ]],\n    bang = true --[[ optional ]]\n  }\n  ```\n\n  - Calling the command with a bang `!` will include dependencies in the search.\n  - You can also influence the behaviour of [`vim.lsp.buf.workspace_symbol()`](https://neovim.io/doc/user/lsp.html#vim.lsp.buf.workspace_symbol())\nby setting the rust-analyzer\n`workspace.symbol.search` server option.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eJoin lines\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Join selected lines into one, smartly fixing up whitespace, trailing commas, and braces.\n  Works with individual lines in normal mode and multiple lines in visual mode.\n\n  ```vim\n  :RustLsp joinLines\n  ```\n  ```lua\n  vim.cmd.RustLsp('joinLines')\n  ```\n\n  ![](https://user-images.githubusercontent.com/1711539/124515923-4504e800-dde9-11eb-8d58-d97945a1a785.gif)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eStructural search replace\u003c/b\u003e\n  \u003c/summary\u003e\n\n  - Searches the entire buffer in normal mode.\n  - Searches the selection in visual mode.\n\n  ```vim\n  :RustLsp ssr {query}\n  ```\n  ```lua\n  vim.cmd.RustLsp { 'ssr', '\u003cquery\u003e' --[[ optional ]] }\n  ```\n\n  ![tty](https://github.com/mrcjkb/rustaceanvim/assets/12857160/b61fbc56-ab53-48e6-bfdd-eb8d4de28795)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eView crate graph\u003c/b\u003e\n  \u003c/summary\u003e\n\n  ```vim\n  :RustLsp crateGraph {backend {output}}\n  ```\n  ```lua\n  vim.cmd.RustLsp { 'crateGraph', '[backend]', '[output]' }\n  ```\n\n  Requires:\n\n  - [`dot` from `graphviz`](https://graphviz.org/doc/info/lang.html)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eView syntax tree\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Requires rust-analyzer \u003e= 2025-01-20.\n\n  ```vim\n  :RustLsp syntaxTree\n  ```\n  ```lua\n  vim.cmd.RustLsp('syntaxTree')\n  ```\n\n  ![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/c865a263-1568-41c7-a32b-bc4a34b198dc)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eFly check\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Run `cargo check` or another compatible command (f.x. `clippy`)\n  in a background thread and provide LSP diagnostics based on\n  the output of the command.\n\n  Useful in large projects where running `cargo check` on each save\n  can be costly.\n\n  ```vim\n  :RustLsp flyCheck {run?|clear?|cancel?}\n  ```\n  ```lua\n  vim.cmd.RustLsp('flyCheck') -- defaults to 'run'\n  vim.cmd.RustLsp { 'flyCheck', 'run' }\n  vim.cmd.RustLsp { 'flyCheck', 'clear' }\n  vim.cmd.RustLsp { 'flyCheck', 'cancel' }\n  ```\n\n  \u003e [!NOTE]\n  \u003e\n  \u003e This is only useful if you set the option,\n  \u003e `['rust-analzyer'].checkOnSave = false`.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eView HIR / MIR\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Opens a buffer with a textual representation of the HIR or MIR\n  of the function containing the cursor.\n  Useful for debugging or when working on rust-analyzer itself.\n\n  ```vim\n  :RustLsp view {hir|mir}\n  ```\n  ```lua\n  vim.cmd.RustLsp { 'view', 'hir' }\n  vim.cmd.RustLsp { 'view', 'mir' }\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eRustc unpretty\u003c/b\u003e\n  \u003c/summary\u003e\n\n  Opens a buffer with a textual representation of the MIR or others things,\n  of the function closest to the cursor.\n  Achieves an experience similar to Rust Playground.\n\n  NOTE: This currently requires a tree-sitter parser for Rust,\n  and a nightly compiler toolchain.\n\n  ```vim\n  :Rustc unpretty {hir|mir|...}\n  ```\n  ```lua\n  vim.cmd.Rustc { 'unpretty', 'hir' }\n  vim.cmd.Rustc { 'unpretty', 'mir' }\n  -- ...\n  ```\n\n  Requires:\n\n  - A tree-sitter parser for Rust (required for the `:Rustc unpretty` command).\n    Can be installed using [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003elspmux\u003c/b\u003e\n  \u003c/summary\u003e\n\n  On Linux and MacOS, rustaceanvim can auto-detect and connect to a\n  running [lspmux](https://codeberg.org/p2502/lspmux) server.\n  By default, it will try to do so automatically if the `vim.g.rustaceanvim.server.cmd`\n  option is unset.\n  See also `:h rustaceanvim.lspmux`.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n  \u003cb\u003eConfigure rust-analyzer on the fly\u003c/b\u003e\n  \u003c/summary\u003e\n\n  You can configure rust-analyzer on the fly using the `:RustAnalyzer config` subcommand.\n  The command takes a Lua table as an argument (it does not validate it!).\n\n  For example:\n\n  ```vim\n  :RustAnalyzer config { checkOnSave = false }\n  ```\n  ```lua\n  vim.cmd.RustAnalyzer { 'config', '{ checkOnSave = false }' }\n  ```\n\n  See also: [`rust-analyzer` configuration](https://rust-analyzer.github.io/book/configuration).\n\u003c/details\u003e\n\u003c!-- markdownlint-restore --\u003e\n\n## :gear: Advanced configuration\n\nTo modify the default configuration, set `vim.g.rustaceanvim`.\n\n- See [`:h rustaceanvim`](./doc/rustaceanvim.txt) for a detailed\n  documentation of all available configuration options.\n  You may need to run `:helptags ALL` if the documentation has not been installed.\n- The default configuration [can be found here (see `RustaceanDefaultConfig`)](./lua/rustaceanvim/config/internal.lua).\n- For detailed descriptions of the language server configs,\n  see the [`rust-analyzer` documentation](https://rust-analyzer.github.io/book/configuration).\n\nYou only need to specify the keys\nthat you want to be changed, because defaults\nare applied for keys that are not provided.\n\nExample config:\n\n```lua\nvim.g.rustaceanvim = {\n  -- Plugin configuration\n  tools = {\n  },\n  -- LSP configuration\n  server = {\n    on_attach = function(client, bufnr)\n      -- you can also put keymaps in here\n    end,\n    default_settings = {\n      -- rust-analyzer language server configuration\n      ['rust-analyzer'] = {\n      },\n    },\n  },\n  -- DAP configuration\n  dap = {\n  },\n}\n```\n\n\u003e [!TIP]\n\u003e\n\u003e - `vim.g.rustaceanvim` can also be a function that returns\n\u003e   a table.\n\u003e\n\u003e - You can also use `:h vim.lsp.config` to configure `vim.g.rustaceanvim.server`\n\u003e   options.\n\u003e   For example, `vim.lsp.config(\"*\", {})` or `vim.lsp.config(\"rust-analyzer\", {})`.\n\n### Using `codelldb` for debugging\n\nFor Rust, `codelldb` from the [CodeLLDB VSCode extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)\nprovides a better experience than `lldb`.\nIf you are using a distribution that lets you install the `codelldb`\nexecutable, this plugin will automatically detect it and configure\nitself to use it as a debug adapter.\n\nSome examples:\n\n- NixOS: [`vscode-extensions.vadimcn.vscode-lldb.adapter`](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/applications/editors/vscode/extensions/vadimcn.vscode-lldb/default.nix#L134)\n- This repository's Nix flake provides a `codelldb` package.\n- Arch Linux: [`codelldb-bin` (AUR)](https://aur.archlinux.org/packages/codelldb-bin)\n- Using [`mason.nvim`](https://github.com/williamboman/mason.nvim):\n  `:MasonInstall codelldb`\n\nIf your distribution does not have a `codelldb` package,\nyou can configure it as follows:\n\n1. Install the [CodeLLDB VSCode extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb).\n1. Find out where it is installed.\n   On Linux, this is typically in `$HOME/.vscode/extensions/`\n1. Update your configuration:\n\n```lua\nvim.g.rustaceanvim = function()\n  -- Update this path\n  local extension_path = vim.env.HOME .. '/.vscode/extensions/vadimcn.vscode-lldb-1.10.0/'\n  local codelldb_path = extension_path .. 'adapter/codelldb'\n  local liblldb_path = extension_path .. 'lldb/lib/liblldb'\n  local this_os = vim.uv.os_uname().sysname;\n\n  -- The path is different on Windows\n  if this_os:find \"Windows\" then\n    codelldb_path = extension_path .. \"adapter\\\\codelldb.exe\"\n    liblldb_path = extension_path .. \"lldb\\\\bin\\\\liblldb.dll\"\n  else\n    -- The liblldb extension is .so for Linux and .dylib for MacOS\n    liblldb_path = liblldb_path .. (this_os == \"Linux\" and \".so\" or \".dylib\")\n  end\n\n  local cfg = require('rustaceanvim.config')\n  return {\n    dap = {\n      adapter = cfg.get_codelldb_adapter(codelldb_path, liblldb_path),\n    },\n  }\nend\n```\n\n### How to dynamically load different `rust-analyzer` settings per project\n\nYou can use the [codesettings.nvim](https://github.com/mrjones2014/codesettings.nvim),\nwhich supports loading project-local LSP from `.vscode/settings.json`[^2],\namong others.\nIf it is installed, rustaceanvim will try to invoke it automatically.\n\n[^2]: See [this example](https://github.com/rust-analyzer/rust-project.json-example/blob/master/.vscode/settings.json)\n      and the rust-analyzer [configuration manual](https://rust-analyzer.github.io/book/configuration).\n\nAnother option is to use `:h exrc`.\n\n## :stethoscope: Troubleshooting\n\n### Health checks\n\nFor a health check, run `:checkhealth rustaceanvim`\n\n### `rust-analyzer` log file\n\nTo open the `rust-analyzer` log file, run `:RustLsp logFile`.\n\n### Minimal config\n\nTo troubleshoot this plugin with a minimal config in a temporary directory,\nyou can try [minimal.lua](./troubleshooting/minimal.lua).\n\n```console\nnvim -u minimal.lua\n```\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e I strongly recommend against using rust-analyzer managed my mason.nvim,\n\u003e as version mismatches between rust-analyzer and your project toolchain\n\u003e can and most likely will lead to subtle issues.\n\nIf you cannot reproduce your issue with a minimal config,\nit may be caused by another plugin,\nor a setting of your plugin manager.\nIn this case, add additional plugins and configurations to `minimal.lua`,\nuntil you can reproduce it.\nOr, bisect your existing plugins and config.\n\n\u003e [!NOTE]\n\u003e\n\u003e If you use Nix, you can run\n\u003e `nix run \"github:mrcjkb/rustaceanvim#nvim-minimal-stable\"`.\n\u003e or\n\u003e `nix run \"github:mrcjkb/rustaceanvim#nvim-minimal-nightly\"`.\n\n### rust-analyzer troubleshooting\n\nFor issues related to rust-analyzer\n(e.g. LSP features not working), see also\n[the rust-analyzer troubleshooting guide](https://rust-analyzer.github.io/book/troubleshooting.html).\n\n### :left_speech_bubble: FAQ\n\n#### Where are inlay hints / type hints?\n\nAs Neovim \u003e= 0.10 supports inlay hints natively,\nI have removed the code from this plugin.\nSee [`:h lsp-inlay_hint`](https://neovim.io/doc/user/lsp.html#lsp-inlay_hint)).\n\n#### Can I display inlay hints to the end of the line?\n\nYou can use the [`nvim-lsp-endhints`](https://github.com/chrisgrieser/nvim-lsp-endhints)\nplugin.\n\n#### How to enable auto completion?\n\nAs of [#ff097f2091e7a970e5b12960683b4dade5563040](https://github.com/neovim/neovim/pull/27339),\nNeovim has built-in completion based on the `triggerCharacters` sent by\nlanguage servers.\nOmni completion is also available for a more traditional `vim`-like completion experience.\n\nFor more extensible and complex autocompletion setups,\nyou need a plugin such as [`nvim-cmp`](https://github.com/hrsh7th/nvim-cmp)\nand a LSP completion source like [`cmp-nvim-lsp`](https://github.com/hrsh7th/cmp-nvim-lsp),\nor you may use [`blink.cmp`](https://github.com/saghen/blink.cmp).\n\n#### I'm having issues with (auto)completion\n\nrustaceanvim doesn't implement (auto)completion.\nIssues with (auto)completion either come from another plugin or rust-analzyer.\n\n#### mason.nvim and nvim-lspconfig\n\nSee [`:h rustaceanvim.mason`](./doc/mason.txt) for details about troubleshooting\nmason.nvim and nvim-lspconfig issues, or configuring rustaceanvim to use\na rust-analyzer installation that is managed by mason.nvim.\n\n#### I am not seeing diagnostics in a standalone file\n\nrust-analyzer has limited support for standalone files.\nMany diagnostics come from Cargo. If you're not in a Cargo project,\nyou won't see any Cargo diagnostics.\n\n#### Debuggable targets aren't being added to nvim-dap\n\nBecause rustaceanvim adds targets automatically when an\nLSP client attaches, it fails silently\nto avoid spamming you with notifications.\nTo troubleshoot your debuggable targets,\nuse `:RustLsp debuggables`.\n\n## :link: Related Projects\n\n- [`cordx56/rustowl`](https://github.com/cordx56/rustowl)\n  Language server to visualize ownership and lifetimes\n  for debugging and optimization.\n  Comes with a Neovim plugin.\n- [`rouge8/neotest-rust`](https://github.com/rouge8/neotest-rust)\n  [`neotest`](https://github.com/nvim-neotest/neotest)\n  adapter for Rust, using [`cargo-nextest`](https://nexte.st/).\n- [`Saecki/crates.nvim`](https://github.com/Saecki/crates.nvim)\n  Neovim plugin that helps managing crates.io dependencies\n- [`vxpm/ferris.nvim`](https://github.com/vxpm/ferris.nvim)\n  Geared towards people who prefer manual LSP client configuration.\n  Has some features that have not yet\n  been implemented by this plugin.\n- [`adaszko/tree_climber_rust.nvim`](https://github.com/adaszko/tree_climber_rust.nvim)\n  tree-sitter powered incremental selection tailored for Rust.\n\n## Inspiration\n\n`rust-tools.nvim` draws inspiration from [`akinsho/flutter-tools.nvim`](https://github.com/akinsho/flutter-tools.nvim)\n\n\u003c!-- markdownlint-disable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n[neovim-shield]: https://img.shields.io/badge/NeoVim-%2357A143.svg?\u0026style=for-the-badge\u0026logo=neovim\u0026logoColor=white\n[neovim-url]: https://neovim.io/\n[lua-shield]: https://img.shields.io/badge/lua-%232C2D72.svg?style=for-the-badge\u0026logo=lua\u0026logoColor=white\n[lua-url]: https://www.lua.org/\n[nix-shield]: https://img.shields.io/badge/nix-0175C2?style=for-the-badge\u0026logo=NixOS\u0026logoColor=white\n[nix-url]: https://nixos.org/\n[rust-shield]: https://img.shields.io/badge/Rust-000000?style=for-the-badge\u0026logo=rust\u0026logoColor=white\n[rust-url]: https://www.rust-lang.org/\n[issues-shield]: https://img.shields.io/github/issues/mrcjkb/rustaceanvim.svg?style=for-the-badge\n[issues-url]: https://github.com/mrcjkb/rustaceanvim/issues\n[license-shield]: https://img.shields.io/github/license/mrcjkb/rustaceanvim.svg?style=for-the-badge\n[license-url]: https://github.com/mrcjkb/rustaceanvim/blob/master/LICENSE\n[ci-shield]: https://img.shields.io/github/actions/workflow/status/mrcjkb/rustaceanvim/nix-build.yml?style=for-the-badge\n[ci-url]: https://github.com/mrcjkb/rustaceanvim/actions/workflows/nix-build.yml\n[luarocks-shield]: https://img.shields.io/luarocks/v/MrcJkb/rustaceanvim?logo=lua\u0026color=purple\u0026style=for-the-badge\n[luarocks-url]: https://luarocks.org/modules/MrcJkb/rustaceanvim\n","funding_links":["https://github.com/sponsors/mrcjkb","https://paypal.me/simrat39","https://www.buymeacoffee.com/simrat39"],"categories":["LSP","Lua"],"sub_categories":["(requires Neovim 0.5)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrcjkb%2Frustaceanvim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrcjkb%2Frustaceanvim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrcjkb%2Frustaceanvim/lists"}