nvim/.config/nvim/lua/plugins/lsp/rust.lua

-- nvim/.config/nvim/lua/plugins/lsp/rust.lua

return {
  {
    "mrcjkb/rustaceanvim",
    version = "^5",
    ft = { "rust" },
    lazy = false,
    init = function()
      vim.g.rustaceanvim = function()
        return {
          server = {
            default_settings = {
              ["rust-analyzer"] = {
                cargo = {
                  allFeatures = true,
                  buildScripts = { enable = true },
                  loadOutDirsFromCheck = true,
                },
                check = {
                  command = "clippy",
                  extraArgs = { "--no-deps" },
                },
                checkOnSave = true,
                diagnostics = {
                  enable = true,
                  disabled = { "inactive-code" },
                  experimental = { enable = true },
                },
                inlayHints = {
                  bindingModeHints       = { enable = false },
                  chainingHints          = { enable = true },
                  closureReturnTypeHints = { enable = "with_block" },
                  lifetimeElisionHints   = { enable = "skip_trivial", useParameterNames = true },
                  parameterHints         = { enable = true },
                  reborrowHints          = { enable = "mutable" },
                  typeHints              = { enable = true, hideClosureInitialization = false },
                },
                procMacro = { enable = true, ignored = { ["async-trait"] = { "async_trait" } } },
                rustfmt   = { extraArgs = { "+nightly" } },
              },
            },
          },
          tools = {
            float_win_config = { border = "rounded" },
            hover_actions    = { replace_builtin_hover = true },
          },
        }
      end
    end,
  },
  {
    "saecki/crates.nvim",
    event = { "BufRead Cargo.toml" },
    opts = { completion = { cmp = { enabled = true } } },
  },
}