mirror of
https://github.com/DefectingCat/nvim
synced 2025-07-15 16:51:33 +00:00
80 lines
2.2 KiB
Lua
80 lines
2.2 KiB
Lua
return {
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
dependencies = {
|
|
{
|
|
"Saecki/crates.nvim",
|
|
event = { "BufRead Cargo.toml" },
|
|
opts = {
|
|
completion = {
|
|
cmp = { enabled = true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
---@param opts cmp.ConfigSchema
|
|
opts = function(_, opts)
|
|
opts.sources = opts.sources or {}
|
|
table.insert(opts.sources, { name = "crates" })
|
|
end,
|
|
},
|
|
{
|
|
"Saecki/crates.nvim",
|
|
event = { "BufRead Cargo.toml" },
|
|
opts = {
|
|
completion = {
|
|
cmp = { enabled = true },
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"mrcjkb/rustaceanvim",
|
|
version = "^4", -- Recommended
|
|
ft = { "rust" },
|
|
opts = {
|
|
server = {
|
|
on_attach = function(_, bufnr)
|
|
vim.keymap.set("n", "<leader>ca", 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 = {
|
|
-- rust-analyzer language server configuration
|
|
["rust-analyzer"] = {
|
|
cargo = {
|
|
allFeatures = 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
|
|
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,
|
|
},
|
|
}
|