This repository was archived by the owner on Jan 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathrust-tools.txt
354 lines (268 loc) · 11.8 KB
/
rust-tools.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
*rust-tools.txt* For NVIM v0.8.0 Last change: 2023 September 25
==============================================================================
Table of Contents *rust-tools-table-of-contents*
1. rust-tools.nvim |rust-tools-rust-tools.nvim|
- Quick Links |rust-tools-rust-tools.nvim-quick-links|
- Prerequisites |rust-tools-rust-tools.nvim-prerequisites|
- Installation |rust-tools-rust-tools.nvim-installation|
- Setup |rust-tools-rust-tools.nvim-setup|
- Usage |rust-tools-rust-tools.nvim-usage|
- Configuration |rust-tools-rust-tools.nvim-configuration|
- Related Projects |rust-tools-rust-tools.nvim-related-projects|
- Inspiration |rust-tools-rust-tools.nvim-inspiration|
==============================================================================
1. rust-tools.nvim *rust-tools-rust-tools.nvim*
A plugin to improve your rust experience in neovim.
QUICK LINKS *rust-tools-rust-tools.nvim-quick-links*
- Wiki <https://github.com/simrat39/rust-tools.nvim/wiki>
- CodeLLDB Debugging <https://github.com/simrat39/rust-tools.nvim/wiki/Debugging>
- Standalone File <https://github.com/simrat39/rust-tools.nvim/wiki/Standalone-File-Support>
- |rust-tools-installation|
- |rust-tools-setup|
- |rust-tools-usage|
PREREQUISITES *rust-tools-rust-tools.nvim-prerequisites*
- `neovim 0.7`
- `nvim-lspconfig`
- `rust-analyzer`
- `dot` from `graphviz` (only for crate graph)
INSTALLATION *rust-tools-rust-tools.nvim-installation*
using `packer.nvim`
>lua
use 'neovim/nvim-lspconfig'
use 'simrat39/rust-tools.nvim'
-- Debugging
use 'nvim-lua/plenary.nvim'
use 'mfussenegger/nvim-dap'
<
Look at the configuration information below to get started.
SETUP *rust-tools-rust-tools.nvim-setup*
This plugin automatically sets up nvim-lspconfig for rust_analyzer for you, so
don’t do that manually, as it causes conflicts.
Put this in your init.lua or any lua file that is sourced.
For most people, the defaults are fine, but for advanced configuration, see
|rust-tools-configuration|.
Example config:
>lua
local rt = require("rust-tools")
rt.setup({
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
end,
},
})
<
USAGE *rust-tools-rust-tools.nvim-usage*
Debugging ~
Inlay Hints ~
```lua – Commands: – RustEnableInlayHints – RustDisableInlayHints –
RustSetInlayHints – RustUnsetInlayHints
– Set inlay hints for the current buffer
require('rust-tools').inlay_hints.set() – Unset inlay hints for the current
buffer require('rust-tools').inlay_hints.unset()
– Enable inlay hints auto update and set them for all the buffers
require('rust-tools').inlay_hints.enable()
– Disable inlay hints auto update and unset them for all buffers
require('rust-tools').inlay_hints.disable()
```Runnables ~
`lua -- Command: -- RustRunnables require('rust-tools').runnables.runnables()`Expand Macros Recursively ~
`lua -- Command: -- RustExpandMacro require'rust-tools'.expand_macro.expand_macro()`Move Item Up/Down ~
`lua -- Command: -- RustMoveItemUp -- RustMoveItemDown local up = true -- true = move up, false = move down require'rust-tools'.move_item.move_item(up)`Hover Actions ~
Note: To activate hover actions, run the command twice (or your hover keymap if you have `hover_with_actions` set to true AND are using `vim.lsp.buf.hover()`). This will move you into the window, then press enter on the selection you want. Alternatively, you can set `auto_focus` to true in your config and you will automatically enter the hover actions window.
`lua -- Command: -- RustHoverActions require'rust-tools'.hover_actions.hover_actions()`Hover Range ~
Note: Requires rust-analyzer version after 2021-08-02. Shows the type in visual mode when hovering.
`lua -- Command: -- RustHoverRange require'rust-tools'.hover_range.hover_range()`Open Cargo.toml ~
`lua -- Command: -- RustOpenCargo require'rust-tools'.open_cargo_toml.open_cargo_toml()`Parent Module ~
`lua -- Command: -- RustParentModule require'rust-tools'.parent_module.parent_module()`Join Lines ~
`lua -- Command: -- RustJoinLines require'rust-tools'.join_lines.join_lines()`Structural Search Replace ~
>lua
-- Command:
-- RustSSR [query]
require'rust-tools'.ssr.ssr(query)
<
View Crate Graph ~
>lua
-- Command:
-- RustViewCrateGraph [backend [output]]
require'rust-tools'.crate_graph.view_crate_graph(backend, output)
<
CONFIGURATION *rust-tools-rust-tools.nvim-configuration*
The options shown below are the defaults. You only need to pass the keys to the
setup function that you want to be changed, because the defaults are applied
for keys that are not provided.
>lua
local opts = {
tools = { -- rust-tools options
-- how to execute terminal commands
-- options right now: termopen / quickfix / toggleterm / vimux
executor = require("rust-tools.executors").termopen,
-- callback to execute once rust-analyzer is done initializing the workspace
-- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error"
on_initialized = nil,
-- automatically call RustReloadWorkspace when writing to a Cargo.toml file.
reload_workspace_from_cargo_toml = true,
-- These apply to the default RustSetInlayHints command
inlay_hints = {
-- automatically set inlay hints (type hints)
-- default: true
auto = true,
-- Only show inlay hints for the current line
only_current_line = false,
-- whether to show parameter hints with the inlay hints or not
-- default: true
show_parameter_hints = true,
-- prefix for parameter hints
-- default: "<-"
parameter_hints_prefix = "<- ",
-- prefix for all the other hints (type, chaining)
-- default: "=>"
other_hints_prefix = "=> ",
-- whether to align to the length of the longest line in the file
max_len_align = false,
-- padding from the left if max_len_align is true
max_len_align_padding = 1,
-- whether to align to the extreme right or not
right_align = false,
-- padding from the right if right_align is true
right_align_padding = 7,
-- The color of the hints
highlight = "Comment",
},
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
hover_actions = {
-- the border that is used for the hover window
-- see vim.api.nvim_open_win()
border = {
{ "╭", "FloatBorder" },
{ "─", "FloatBorder" },
{ "╮", "FloatBorder" },
{ "│", "FloatBorder" },
{ "╯", "FloatBorder" },
{ "─", "FloatBorder" },
{ "╰", "FloatBorder" },
{ "│", "FloatBorder" },
},
-- Maximal width of the hover window. Nil means no max.
max_width = nil,
-- Maximal height of the hover window. Nil means no max.
max_height = nil,
-- whether the hover action window gets automatically focused
-- default: false
auto_focus = false,
},
-- settings for showing the crate graph based on graphviz and the dot
-- command
crate_graph = {
-- Backend used for displaying the graph
-- see: https://graphviz.org/docs/outputs/
-- default: x11
backend = "x11",
-- where to store the output, nil for no output stored (relative
-- path from pwd)
-- default: nil
output = nil,
-- true for all crates.io and external crates, false only the local
-- crates
-- default: true
full = true,
-- List of backends found on: https://graphviz.org/docs/outputs/
-- Is used for input validation and autocompletion
-- Last updated: 2021-08-26
enabled_graphviz_backends = {
"bmp",
"cgimage",
"canon",
"dot",
"gv",
"xdot",
"xdot1.2",
"xdot1.4",
"eps",
"exr",
"fig",
"gd",
"gd2",
"gif",
"gtk",
"ico",
"cmap",
"ismap",
"imap",
"cmapx",
"imap_np",
"cmapx_np",
"jpg",
"jpeg",
"jpe",
"jp2",
"json",
"json0",
"dot_json",
"xdot_json",
"pdf",
"pic",
"pct",
"pict",
"plain",
"plain-ext",
"png",
"pov",
"ps",
"ps2",
"psd",
"sgi",
"svg",
"svgz",
"tga",
"tiff",
"tif",
"tk",
"vml",
"vmlz",
"wbmp",
"webp",
"xlib",
"x11",
},
},
},
-- all the opts to send to nvim-lspconfig
-- these override the defaults set by rust-tools.nvim
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
server = {
-- standalone file support
-- setting it to false may improve startup time
standalone = true,
}, -- rust-analyzer options
-- debugging stuff
dap = {
adapter = {
type = "executable",
command = "lldb-vscode",
name = "rt_lldb",
},
},
}
require('rust-tools').setup(opts)
<
RELATED PROJECTS *rust-tools-rust-tools.nvim-related-projects*
- `Saecki/crates.nvim` <https://github.com/Saecki/crates.nvim>
INSPIRATION *rust-tools-rust-tools.nvim-inspiration*
This plugin draws inspiration from `akinsho/flutter-tools.nvim`
<https://github.com/akinsho/flutter-tools.nvim>
==============================================================================
2. Links *rust-tools-links*
1. *debugging*: https://github.com/simrat39/rust-tools-demos/raw/master/rust-tools-debug.gif
2. *inlay hints*: https://github.com/simrat39/rust-tools-demos/raw/master/inlay_hints.png
3. *runnables*: https://github.com/simrat39/rust-tools-demos/raw/master/runnables.gif
4. *expand macros*: https://github.com/simrat39/rust-tools-demos/raw/master/expand_macros_recursively.gif
5. *move items*: https://github.com/simrat39/rust-tools-demos/raw/master/move_item.gif
6. *hover actions*: https://github.com/simrat39/rust-tools-demos/raw/master/hover_actions.gif
7. *open cargo*: https://github.com/simrat39/rust-tools-demos/raw/master/open_cargo_toml.gif
8. *parent module*: https://github.com/simrat39/rust-tools-demos/raw/master/parent_module.gif
9. *join lines*: https://github.com/simrat39/rust-tools-demos/raw/master/join_lines.gif
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
vim:tw=78:ts=8:noet:ft=help:norl: