vim.pack.add { { src = "https://github.com/mrcjkb/rustaceanvim", version = vim.version.range("^7") } } vim.g.rustaceanvim = { -- Plugin configuration tools = {}, -- LSP configuration server = { on_attach = function(_, bufnr) -- vim.keymap.set({ "n", "v" }, "gra", function() -- vim.cmd.RustLsp("codeAction") -- supports rust-analyzer's grouping -- end, { silent = true, buffer = bufnr, desc = "Code action" }) vim.keymap.set( "n", "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions function() vim.cmd.RustLsp { "hover", "actions" } end, { silent = true, buffer = bufnr } ) vim.keymap.set( "n", "gre", function() vim.cmd.RustLsp { "expandMacro" } end, { silent = true, buffer = bufnr, desc = "Expand macro" } ) vim.keymap.set( "n", "grd", function() vim.cmd.RustLsp { "openDocs" } end, { silent = true, buffer = bufnr, desc = "Open docs.rs" } ) end, default_settings = { -- rust-analyzer language server configuration ["rust-analyzer"] = { cargo = { allFeatures = true, loadOutDirsFromCheck = true, buildScripts = { enable = true, }, }, -- Add clippy lints for Rust. checkOnSave = true, check = { allTargets = false, allFeatures = true, workspace = true, command = "clippy", }, diagnostics = { enable = true }, procMacro = { enable = true, ignored = { -- ["async-trait"] = { "async_trait" }, ["napi-derive"] = { "napi" }, ["async-recursion"] = { "async_recursion" }, }, }, inlayHints = { lifetimeElisionHints = { enable = true, useParameterNames = true, }, }, completion = { excludeTraits = { "owo_colors::OwoColorize", "color_eyre::owo_colors::OwoColorize", }, }, server = { extraEnv = { ["LD_LIBRARY_PATH"] = "/usr/local/lib:/usr/lib", }, }, files = { excludeDirs = { ".direnv", ".git", ".github", ".gitlab", "bin", "node_modules", "target", "venv", ".venv", }, }, }, }, }, -- TODO: add nvim-dap -- DAP configuration -- dap = {}, }