]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lang/rust.lua
nvim: add todo to review clipboard providers
[dotfiles.git] / nvim / lua / plugins / lang / rust.lua
1 return {
2 { "Saecki/crates.nvim",
3 event = { "BufRead Cargo.toml" },
4 opts = {
5 completion = {
6 crates = {
7 enabled = true,
8 },
9 },
10 lsp = {
11 enabled = true,
12 actions = true,
13 completion = true,
14 hover = true,
15 },
16 },
17 },
18 { "nvim-treesitter/nvim-treesitter",
19 opts = { ensure_installed = { "rust", "ron" } },
20 },
21 { "williamboman/mason.nvim",
22 optional = true,
23 opts = function(_, opts)
24 opts.ensure_installed = opts.ensure_installed or {}
25 vim.list_extend(opts.ensure_installed, { "codelldb" })
26 end,
27 },
28 { "mrcjkb/rustaceanvim",
29 version = vim.fn.has("nvim-0.10.0") == 0 and "^4" or false,
30 ft = { "rust" },
31 opts = {
32 server = {
33 on_attach = function(_, bufnr)
34 vim.keymap.set("n", "<leader>cR", function()
35 vim.cmd.RustLsp("codeAction")
36 end, { desc = "Code Action", buffer = bufnr })
37 vim.keymap.set("n", "<leader>dr", function()
38 vim.cmd.RustLsp("debuggables")
39 end, { desc = "Rust Debuggables", buffer = bufnr })
40 end,
41 default_settings = {
42 -- rust-analyzer language server configuration
43 ["rust-analyzer"] = {
44 cargo = {
45 allFeatures = true,
46 loadOutDirsFromCheck = true,
47 buildScripts = {
48 enable = true,
49 },
50 },
51 -- Add clippy lints for Rust if using rust-analyzer
52 checkOnSave = true,
53 -- Enable diagnostics if using rust-analyzer
54 diagnostics = {
55 enable = true,
56 },
57 procMacro = {
58 enable = true,
59 ignored = {
60 ["async-trait"] = { "async_trait" },
61 ["napi-derive"] = { "napi" },
62 ["async-recursion"] = { "async_recursion" },
63 },
64 },
65 files = {
66 excludeDirs = {
67 ".direnv",
68 ".git",
69 ".github",
70 ".gitlab",
71 "bin",
72 "node_modules",
73 "target",
74 "venv",
75 ".venv",
76 },
77 },
78 },
79 },
80 },
81 },
82 },
83 { "neovim/nvim-lspconfig",
84 opts = {
85 servers = {
86 rust_analyzer = { enabled = false }, -- rustaceanvim is used instead
87 },
88 },
89 },
90 { "nvim-neotest/neotest",
91 optional = true,
92 opts = {
93 adapters = {
94 ["rustaceanvim.neotest"] = {},
95 },
96 },
97 },
98 }