Rust

Install Syntax Highlighting

:TSInstall rust
1

Install Language Server

:LspInstall rust_analyzer
1

Formatters

The configured formatter(s) must be installed separately.

Configuration in ~/.config/lvim/config.lua:

-- exe value can be "rustfmt"
lvim.lang.rust.formatters = { { exe = "rustfmt" } }
1
2

LSP Settings

:NlspConfig rust_analyzer
1

Debugger

:DIInstall ccppr_lldb
1
-- ~/.config/lvim/ftplugin/rust.lua
local dap_install = require "dap-install"
dap_install.config("rust", {})
1
2
3

Extra Plugins

lvim.lsp.override = { "rust" }
lvim.plugins = {
  {
    "simrat39/rust-tools.nvim",
    config = function()
      require("rust-tools").setup({
        tools = {
          autoSetHints = true,
          hover_with_actions = true,
          runnables = {
            use_telescope = true,
          },
        },
        server = {
          cmd = { vim.fn.stdpath "data" .. "/lsp_servers/rust/rust-analyzer" },
          on_attach = require("lvim.lsp").common_on_attach,
          on_init = require("lvim.lsp").common_on_init,
        },
        })
    end,
    ft = { "rust", "rs" },
  },
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23