local rok, rust_settings = pcall(require, "rua.config.rust-analyzer") if not rok then return {} else return { { "Saecki/crates.nvim", event = { "BufRead Cargo.toml" }, keys = { { "cu", function() require("crates").upgrade_all_crates() end, desc = "Update crates", }, }, opts = { completion = { cmp = { enabled = true }, }, }, }, { "mrcjkb/rustaceanvim", version = "^6", -- Recommended ft = { "rust" }, opts = { server = { on_attach = function(_, bufnr) local map = vim.keymap.set local opts = { buffer = bufnr, silent = true } map("n", "ca", function() vim.cmd.RustLsp("codeAction") end, { desc = "Code Action", buffer = bufnr }) map("n", "da", function() vim.cmd.RustLsp("debuggables") end, { desc = "Rust Debuggables", buffer = bufnr }) map("n", "gh", function() vim.cmd.RustLsp({ "hover", "actions" }) end, { silent = true, buffer = bufnr }) opts.desc = "Show LSP references" map("n", "gr", "Telescope lsp_references", opts) -- show definition, references opts.desc = "Go to declaration" map("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration opts.desc = "Show LSP definitions" map("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions opts.desc = "Show LSP implementations" map("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations opts.desc = "Show LSP type definitions" map("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions end, default_settings = rust_settings.settings, }, }, config = function(_, opts) vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {}) if vim.fn.executable("rust-analyzer") == 0 then print("**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/") -- LazyVim.error( -- "**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/", -- { title = "rustaceanvim" } -- ) end end, }, } end