|
1 | 1 | return { |
2 | | - -- Rust-tools |
| 2 | + -- rustaceanvim: native LSP API Rust support (replaces archived rust-tools.nvim) |
3 | 3 | { |
4 | | - "simrat39/rust-tools.nvim", |
5 | | - dependencies = { |
6 | | - "neovim/nvim-lspconfig", |
7 | | - "nvim-lua/plenary.nvim", |
8 | | - "mfussenegger/nvim-dap", |
9 | | - }, |
10 | | - enabled = true, |
11 | | - ft = { "rust", "toml" }, |
12 | | - config = function() |
13 | | - local handlers = require("lsp.handlers") |
14 | | - local extension_path = require("mason-registry").get_package("codelldb"):get_install_path() .. "/extension/" |
15 | | - local codelldb_path = extension_path .. "adapter/codelldb" |
16 | | - local liblldb_path = extension_path .. "lldb/lib/liblldb.so" |
17 | | - local rust_tools = require("rust-tools") |
18 | | - |
19 | | - rust_tools.setup({ |
| 4 | + "mrcjkb/rustaceanvim", |
| 5 | + version = "^5", |
| 6 | + lazy = false, |
| 7 | + init = function() |
| 8 | + vim.g.rustaceanvim = { |
20 | 9 | tools = { |
21 | | - executor = require("rust-tools.executors").termopen, |
22 | | - autoSetHints = true, |
23 | | - runnables = { |
24 | | - use_telescope = true, |
25 | | - }, |
26 | | - reload_workspace_from_cargo_toml = true, |
27 | | - on_initialized = function() |
28 | | - vim.cmd([[ |
29 | | - augroup RustLSP |
30 | | - autocmd CursorHold *.rs silent! lua vim.lsp.buf.document_highlight() |
31 | | - autocmd CursorMoved,InsertEnter *.rs silent! lua vim.lsp.buf.clear_references() |
32 | | - autocmd BufEnter,CursorHold,InsertLeave *.rs silent! lua vim.lsp.codelens.refresh() |
33 | | - augroup END |
34 | | - ]]) |
35 | | - end, |
36 | | - inlay_hints = { |
37 | | - auto = false, |
38 | | - only_current_line = false, |
39 | | - show_parameter_hints = true, |
40 | | - parameter_hints_prefix = "<- ", |
41 | | - other_hints_prefix = "=> ", |
42 | | - max_len_align = false, |
43 | | - max_len_align_padding = 1, |
44 | | - right_align = false, |
45 | | - right_align_padding = 7, |
46 | | - highlight = "Comment", |
47 | | - }, |
48 | | - hover_actions = { |
49 | | - border = { |
50 | | - { "╭", "FloatBorder" }, |
51 | | - { "─", "FloatBorder" }, |
52 | | - { "╮", "FloatBorder" }, |
53 | | - { "│", "FloatBorder" }, |
54 | | - { "╯", "FloatBorder" }, |
55 | | - { "─", "FloatBorder" }, |
56 | | - { "╰", "FloatBorder" }, |
57 | | - { "│", "FloatBorder" }, |
58 | | - }, |
59 | | - max_width = nil, |
60 | | - max_height = nil, |
61 | | - auto_focus = true, |
62 | | - }, |
63 | | - crate_graph = { |
64 | | - backend = "x11", |
65 | | - output = nil, |
66 | | - full = true, |
67 | | - enabled_graphviz_backends = { |
68 | | - "bmp", |
69 | | - "cgimage", |
70 | | - "canon", |
71 | | - "dot", |
72 | | - "gv", |
73 | | - "xdot", |
74 | | - "xdot1.2", |
75 | | - "xdot1.4", |
76 | | - "eps", |
77 | | - "exr", |
78 | | - "fig", |
79 | | - "gd", |
80 | | - "gd2", |
81 | | - "gif", |
82 | | - "gtk", |
83 | | - "ico", |
84 | | - "cmap", |
85 | | - "ismap", |
86 | | - "imap", |
87 | | - "cmapx", |
88 | | - "imap_np", |
89 | | - "cmapx_np", |
90 | | - "jpg", |
91 | | - "jpeg", |
92 | | - "jpe", |
93 | | - "jp2", |
94 | | - "json", |
95 | | - "json0", |
96 | | - "dot_json", |
97 | | - "xdot_json", |
98 | | - "pdf", |
99 | | - "pic", |
100 | | - "pct", |
101 | | - "pict", |
102 | | - "plain", |
103 | | - "plain-ext", |
104 | | - "png", |
105 | | - "pov", |
106 | | - "ps", |
107 | | - "ps2", |
108 | | - "psd", |
109 | | - "sgi", |
110 | | - "svg", |
111 | | - "svgz", |
112 | | - "tga", |
113 | | - "tiff", |
114 | | - "tif", |
115 | | - "tk", |
116 | | - "vml", |
117 | | - "vmlz", |
118 | | - "wbmp", |
119 | | - "webp", |
120 | | - "xlib", |
121 | | - "x11", |
122 | | - }, |
123 | | - }, |
| 10 | + hover_actions = { auto_focus = true }, |
124 | 11 | }, |
125 | | - server = { |
126 | | - on_attach = function(_, bufnr) |
127 | | - handlers.on_attach(_, bufnr) |
128 | | - wk = require("which-key") |
129 | | - wk.add({ |
130 | | - { "<leader>dE", "<cmd>RustDebuggables<cr>", desc = "[RUST] Show debug configurations" }, |
131 | | - { "<leader>de", "<cmd>RustLastDebug<cr>", desc = "[RUST] Debug last" }, |
132 | | - { "<leader>dR", "<cmd>RustRun<cr>", desc = "[RUST] Show run configurations" }, |
133 | | - { "<leader>dr", "<cmd>RustLastRun<cr>", desc = "[RUST] Run last" }, |
| 12 | + } |
| 13 | + -- Rust-specific keymaps; global on_attach is wired in lsp/init.lua via LspAttach |
| 14 | + vim.api.nvim_create_autocmd("LspAttach", { |
| 15 | + callback = function(args) |
| 16 | + local client = vim.lsp.get_client_by_id(args.data.client_id) |
| 17 | + if client and client.name == "rust_analyzer" then |
| 18 | + require("which-key").add({ |
| 19 | + { "<leader>dE", "<cmd>RustLsp debuggables<cr>", desc = "[RUST] Show debuggables", buffer = args.buf }, |
| 20 | + { "<leader>de", "<cmd>RustLsp! debuggables<cr>", desc = "[RUST] Debug last", buffer = args.buf }, |
| 21 | + { "<leader>dR", "<cmd>RustLsp runnables<cr>", desc = "[RUST] Show runnables", buffer = args.buf }, |
| 22 | + { "<leader>dr", "<cmd>RustLsp! runnables<cr>", desc = "[RUST] Run last", buffer = args.buf }, |
134 | 23 | }) |
135 | | - end, |
136 | | - capabilities = handlers.capabilities, |
137 | | - standalone = false, |
138 | | - }, |
139 | | - dap = { |
140 | | - adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path), |
141 | | - }, |
| 24 | + end |
| 25 | + end, |
142 | 26 | }) |
143 | 27 | end, |
144 | 28 | }, |
145 | | - -- Crates |
| 29 | + -- crates.nvim: Cargo.toml dependency management |
146 | 30 | { |
147 | 31 | "saecki/crates.nvim", |
148 | 32 | enabled = true, |
149 | | - event = { "BufRead Cargo.toml" }, |
| 33 | + event = { "BufRead Cargo.toml" }, |
150 | 34 | tag = "v0.4.0", |
151 | 35 | lazy = true, |
152 | 36 | dependencies = { "nvim-lua/plenary.nvim" }, |
153 | 37 | config = function() |
154 | 38 | require("crates").setup({ |
155 | | - src = { |
156 | | - --[[ coq = { |
157 | | - enabled = true, |
158 | | - name = "crates.nvim", |
159 | | - }, ]] |
160 | | - cmp = { |
161 | | - enabled = true, |
162 | | - }, |
163 | | - }, |
164 | | - popup = { |
165 | | - border = "rounded", |
166 | | - }, |
| 39 | + src = { cmp = { enabled = true } }, |
| 40 | + popup = { border = "rounded" }, |
167 | 41 | }) |
168 | 42 | end, |
169 | 43 | }, |
|
0 commit comments