rust: full config

main
Zynh Ludwig 2024-07-30 00:20:40 -07:00
parent eb44c9410c
commit 00629796bb
1 changed files with 34 additions and 0 deletions

View File

@ -1,15 +1,49 @@
return { return {
"mrcjkb/rustaceanvim", "mrcjkb/rustaceanvim",
version = "^4", -- Recommended
ft = { "rust" },
opts = { opts = {
server = { server = {
on_attach = function(_, bufnr)
vim.keymap.set("n", "<leader>cR", function()
vim.cmd.RustLsp("codeAction")
end, { desc = "Code Action", buffer = bufnr })
vim.keymap.set("n", "<leader>dr", function()
vim.cmd.RustLsp("debuggables")
end, { desc = "Rust Debuggables", buffer = bufnr })
end,
default_settings = { default_settings = {
-- rust-analyzer language server configuration -- rust-analyzer language server configuration
["rust-analyzer"] = { ["rust-analyzer"] = {
cargo = { cargo = {
allFeatures = true,
targetDir = true, targetDir = true,
loadOutDirsFromCheck = true,
buildScripts = {
enable = true,
},
},
-- Add clippy lints for Rust.
checkOnSave = true,
procMacro = {
enable = true,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
}, },
}, },
}, },
}, },
}, },
},
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
LazyVim.error(
"**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/",
{ title = "rustaceanvim" }
)
end
end,
} }