robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:880cf88: runtime(doc): Various fixes for ft_rust.txt (tw78, grammar, spaces) (#38730)33b9a9dcf1

master
16.5 KiB466 linesraw
1*ft_rust.txt*	Filetype plugin for Rust
2
3==============================================================================
4CONTENTS					*rust*
5
61. Introduction					|rust-intro|
72. Settings					|rust-settings|
83. Commands					|rust-commands|
94. Mappings					|rust-mappings|
10
11==============================================================================
12INTRODUCTION					*rust-intro*
13
14This plugin provides syntax and supporting functionality for the Rust
15filetype.
16
17==============================================================================
18SETTINGS					*rust-settings*
19
20This plugin has a few variables you can define in your vimrc that change the
21behavior of the plugin.
22
23Some variables can be set buffer local (`b:` prefix), and the buffer local
24will take precedence over the global `g:` counterpart.
25
26						*g:rustc_path*
27g:rustc_path ~
28	Set this option to the path to rustc for use in the |:RustRun| and
29	|:RustExpand| commands.  If unset, "rustc" will be located in $PATH: >vim
30		let g:rustc_path = $HOME."/bin/rustc"
31<
32						*g:rustc_makeprg_no_percent*
33g:rustc_makeprg_no_percent ~
34	Set this option to 1 to have 'makeprg' default to "rustc" instead of
35	"rustc %": >vim
36		let g:rustc_makeprg_no_percent = 1
37<
38						*g:rust_conceal*
39g:rust_conceal ~
40	Set this option to turn on the basic |conceal| support: >vim
41		let g:rust_conceal = 1
42<
43						*g:rust_conceal_mod_path*
44g:rust_conceal_mod_path ~
45	Set this option to turn on |conceal| for the path connecting token "::": >vim
46		let g:rust_conceal_mod_path = 1
47<
48						*g:rust_conceal_pub*
49g:rust_conceal_pub ~
50	Set this option to turn on |conceal| for the "pub" token: >vim
51		let g:rust_conceal_pub = 1
52<
53						*g:rust_recommended_style*
54g:rust_recommended_style ~
55	Set this option to enable vim indentation and textwidth settings to
56	conform to style conventions of the Rust style guide (i.e. use 4
57	spaces for indents and set 'textwidth' to 100).  This option is
58	enabled by default.  To disable it: >vim
59		let g:rust_recommended_style = 0
60<
61						*g:rust_fold*
62g:rust_fold ~
63	Set this option to turn on |folding|: >vim
64		let g:rust_fold = 1
65<
66	Value	Effect  ~
67	0	No folding
68	1	Braced blocks are folded.  All folds are open by default.
69	2	Braced blocks are folded. 'foldlevel' is left at the global
70		value (all folds are closed by default).
71
72						*g:rust_bang_comment_leader*
73g:rust_bang_comment_leader ~
74	Set this option to 1 to preserve the leader on multi-line doc comments
75	using the `/*!` syntax: >vim
76		let g:rust_bang_comment_leader = 1
77<
78						*g:rust_use_custom_ctags_defs*
79g:rust_use_custom_ctags_defs ~
80	Set this option to 1 if you have customized ctags definitions for Rust
81	and do not wish for those included with rust.vim to be used: >vim
82		let g:rust_use_custom_ctags_defs = 1
83<
84
85	NOTE: rust.vim's built-in definitions are only used for the Tagbar Vim
86	plugin, if you have it installed, AND if Universal Ctags is not
87	detected.  This is because Universal Ctags already has built-in
88	support for Rust when used with Tagbar.
89
90	Also, note that when using ctags other than Universal Ctags, it is not
91	automatically used when generating |tags| files that Vim can use to
92	navigate to definitions across different source files.  Feel free to
93	copy `rust.vim/ctags/rust.ctags` into your own `~/.ctags` if you wish
94	to generate |tags| files.
95
96						*g:ftplugin_rust_source_path*
97g:ftplugin_rust_source_path ~
98	Set this option to a path that should be prepended to 'path' for Rust
99	source files: >vim
100		let g:ftplugin_rust_source_path = $HOME . '/dev/rust'
101<
102						*g:rustfmt_command*
103g:rustfmt_command ~
104	Set this option to the name of the "rustfmt" executable in your $PATH.
105	If not specified it defaults to "rustfmt": >vim
106		let g:rustfmt_command = 'rustfmt'
107<
108						*g:rustfmt_autosave*
109						*b:rustfmt_autosave*
110g:rustfmt_autosave ~
111	Set this option to 1 to run |:RustFmt| automatically when saving a
112	buffer.  If not specified it defaults to 0: >vim
113		let g:rustfmt_autosave = 0
114<
115	There is also a buffer-local b:rustfmt_autosave that can be set for
116	the same purpose, and can override the global setting.
117
118					*g:rustfmt_autosave_if_config_present*
119					*b:rustfmt_autosave_if_config_present*
120g:rustfmt_autosave_if_config_present ~
121	Set this option to 1 to have |b:rustfmt_autosave| be set automatically
122	if a `rustfmt.toml` file is present in any parent directory leading to
123	the file being edited.  If not set, default to 0: >vim
124		let g:rustfmt_autosave_if_config_present = 0
125<
126	This is useful to have `rustfmt` only execute on save, on projects
127	that have `rustfmt.toml` configuration.
128
129	There is also a buffer-local b:rustfmt_autosave_if_config_present
130	that can be set for the same purpose, which can override the global
131	setting.
132						*g:rustfmt_fail_silently*
133g:rustfmt_fail_silently ~
134	Set this option to 1 to prevent "rustfmt" from populating the
135	|location-list| with errors.  If not specified it defaults to 0: >vim
136		let g:rustfmt_fail_silently = 0
137<
138						*g:rustfmt_options*
139g:rustfmt_options ~
140	Set this option to a string of options to pass to "rustfmt".
141	The write-mode is already set to "overwrite".  If not specified it
142	defaults to '': >vim
143		let g:rustfmt_options = ''
144<
145						*g:rustfmt_emit_files*
146g:rustfmt_emit_files ~
147	If not specified rust.vim tries to detect the right parameter to
148	pass to rustfmt based on its reported version.  Otherwise, it
149	determines whether to run rustfmt with "--emit=files" (when 1 is
150	provided) instead of "--write-mode=overwrite". >vim
151		let g:rustfmt_emit_files = 0
152<
153						*g:rustfmt_detect_version*
154g:rustfmt_detect_version ~
155	When set to 1, will try to parse the version output from "rustfmt".
156	Disabled by default for performance reasons. >vim
157		let g:rustfmt_detect_version = 1
158<
159						*g:rustfmt_find_toml*
160g:rustfmt_find_toml ~
161	When set to 1, will try to find `rustfmt.toml` file by searching from
162	current path upwards.  Disabled by default for performance reasons. >vim
163		let g:rustfmt_find_toml = 1
164<
165						*g:rust_playpen_url*
166g:rust_playpen_url ~
167	Set this option to override the url for the playpen to use: >vim
168		let g:rust_playpen_url = 'https://play.rust-lang.org/'
169<
170						*g:rust_shortener_url*
171g:rust_shortener_url ~
172	Set this option to override the url for the url shortener: >vim
173		let g:rust_shortener_url = 'https://is.gd/'
174<
175						*g:rust_clip_command*
176g:rust_clip_command ~
177	Set this option to the command used in your OS to copy the Rust Play
178	url to the clipboard: >vim
179		let g:rust_clip_command = 'xclip -selection clipboard'
180<
181						*g:cargo_makeprg_params*
182g:cargo_makeprg_params ~
183	Set this option to the string of parameters to pass to cargo.  If not
184	specified it defaults to `$*`: >vim
185		let g:cargo_makeprg_params = 'build'
186<
187						*g:cargo_shell_command_runner*
188g:cargo_shell_command_runner ~
189	Set this option to change how to run shell commands for cargo commands
190	|:Cargo|, |:Cbuild|, |:Crun|, etc. - see |rust-commands|.
191	By default, |:terminal| is used to run a shell command in a terminal
192	window asynchronously.  But if you prefer |:!| for running the
193	commands, it can be specified: >vim
194		let g:cargo_shell_command_runner = '!'
195<
196------------------------------------------------------------------------------
197Integration with Syntastic			*rust-syntastic*
198
199This plugin automatically integrates with the Syntastic checker.  There are
200two checkers provided: `rustc`, and `cargo`.  The latter invokes `cargo` to
201build code, and the former delivers a single edited ".rs" file as a
202compilation target directly to the Rust compiler, `rustc`.
203
204Because Cargo is almost exclusively being used for building Rust code these
205days, `cargo` is the default checker.
206>vim
207	let g:syntastic_rust_checkers = ['cargo']
208<
209If you would like to change it, you can set `g:syntastic_rust_checkers` to a
210different value.
211					*g:rust_cargo_avoid_whole_workspace*
212					*b:rust_cargo_avoid_whole_workspace*
213g:rust_cargo_avoid_whole_workspace ~
214	When editing a crate that is part of a Cargo workspace, and this
215	option is set to 1 (the default), then `cargo` will be executed
216	directly in that crate directory instead of in the workspace
217	directory.  Setting 0 prevents this behavior - however be aware that
218	if you are working in a large workspace, Cargo commands may take more
219	time, plus the Syntastic error list may include all the crates in the
220	workspace. >vim
221		let g:rust_cargo_avoid_whole_workspace = 0
222<
223					*g:rust_cargo_check_all_targets*
224					*b:rust_cargo_check_all_targets*
225g:rust_cargo_check_all_targets ~
226	When set to 1, the `--all-targets` option will be passed to cargo when
227	Syntastic executes it, allowing the linting of all targets under the
228	package.
229	The default is 0.
230					*g:rust_cargo_check_all_features*
231					*b:rust_cargo_check_all_features*
232g:rust_cargo_check_all_features ~
233	When set to 1, the `--all-features` option will be passed to cargo when
234	Syntastic executes it, allowing the linting of all features of the
235	package.
236	The default is 0.
237					*g:rust_cargo_check_examples*
238					*b:rust_cargo_check_examples*
239g:rust_cargo_check_examples ~
240	When set to 1, the `--examples` option will be passed to cargo when
241	Syntastic executes it, to prevent the exclusion of examples from
242	linting.  The examples are normally under the `examples/` directory of
243	the crate.
244	The default is 0.
245					*g:rust_cargo_check_tests*
246					*b:rust_cargo_check_tests*
247g:rust_cargo_check_tests ~
248	When set to 1, the `--tests` option will be passed to cargo when
249	Syntastic executes it, to prevent the exclusion of tests from linting.
250	The tests are normally under the `tests/` directory of the crate.
251	The default is 0.
252					*g:rust_cargo_check_benches*
253					*b:rust_cargo_check_benches*
254g:rust_cargo_check_benches ~
255	When set to 1, the `--benches` option will be passed to cargo when
256	Syntastic executes it.  The benches are normally under the `benches/`
257	directory of the crate.
258	The default is 0.
259
260------------------------------------------------------------------------------
261Integration with auto-pairs		*rust-auto-pairs*
262
263This plugin automatically configures the auto-pairs plugin not to duplicate
264single quotes, which are used more often for lifetime annotations than for
265single character literals.
266
267					*g:rust_keep_autopairs_default*
268g:rust_keep_autopairs_default ~
269	Don't override auto-pairs default for the Rust filetype.  The default
270	is 0.
271
272==============================================================================
273COMMANDS						*rust-commands*
274
275Invoking Cargo ~
276
277This plugin defines very simple shortcuts for invoking Cargo from within Vim.
278
279:Cargo <args>						*:Cargo*
280		Runs `cargo` with the provided arguments.
281
282:Cbuild <args>						*:Cbuild*
283		Shortcut for `cargo build`.
284
285:Cclean <args>						*:Cclean*
286		Shortcut for `cargo clean`.
287
288:Cdoc <args>						*:Cdoc*
289		Shortcut for `cargo doc`.
290
291:Cinit <args>						*:Cinit*
292		Shortcut for `cargo init`.
293
294:Crun <args>						*:Crun*
295		Shortcut for `cargo run`.
296
297:Ctest <args>						*:Ctest*
298		Shortcut for `cargo test`.
299
300:Cupdate <args>						*:Cupdate*
301		Shortcut for `cargo update`.
302
303:Cbench <args>						*:Cbench*
304		Shortcut for `cargo bench`.
305
306:Csearch <args>						*:Csearch*
307		Shortcut for `cargo search`.
308
309:Cpublish <args>					*:Cpublish*
310		Shortcut for `cargo publish`.
311
312:Cinstall <args>					*:Cinstall*
313		Shortcut for `cargo install`.
314
315:Cruntarget <args>					*:Cruntarget*
316		Shortcut for `cargo run --bin` or `cargo run --example`,
317		depending on the currently open buffer.
318
319Formatting ~
320
321:RustFmt						*:RustFmt*
322		Runs |g:rustfmt_command| on the current buffer.  If
323		|g:rustfmt_options| is set then those will be passed to the
324		executable.
325
326		If |g:rustfmt_fail_silently| is 0 (the default) then it
327		will populate the |location-list| with the errors from
328		|g:rustfmt_command|.  If |g:rustfmt_fail_silently| is set to 1
329		then it will not populate the |location-list|.
330
331:RustFmtRange						*:RustFmtRange*
332		Runs |g:rustfmt_command| with selected range.  See |:RustFmt|
333		for any other information.
334
335Playpen integration ~
336
337:RustPlay						*:RustPlay*
338		This command will only work if you have web-api.vim installed
339		(available at https://github.com/mattn/webapi-vim).  It sends
340		the current selection, or if nothing is selected, the entirety
341		of the current buffer to the Rust playpen, and emits a message
342		with the shortened URL to the playpen.
343
344		|g:rust_playpen_url| is the base URL to the playpen, by default
345		"https://play.rust-lang.org/".
346
347		|g:rust_shortener_url| is the base url for the shortener, by
348		default "https://is.gd/"
349
350		|g:rust_clip_command| is the command to run to copy the
351		playpen url to the clipboard of your system.
352
353Evaluation of a single Rust file ~
354
355NOTE: These commands are useful only when working with standalone Rust files,
356which is usually not the case for common Rust development.  If you wish to
357build Rust crates from within Vim, use Vim's make, Syntastic, or functionality
358from other plugins.
359
360:RustRun  [args]					*:RustRun*
361:RustRun! [rustc-args] [--] [args]
362		Compiles and runs the current file.  If it has unsaved
363		changes, it will be saved first using |:update|.  If the
364		current file is an unnamed buffer, it will be written to a
365		temporary file first.  The compiled binary is always placed in
366		a temporary directory, but is run from the current directory.
367
368		The arguments given to |:RustRun| will be passed to the
369		compiled binary.
370
371		If ! is specified, the arguments are passed to rustc instead.
372		A "--" argument will separate the rustc arguments from the
373		arguments passed to the binary.
374
375		If |g:rustc_path| is defined, it is used as the path to rustc.
376		Otherwise it is assumed rustc can be found in $PATH.
377
378:RustExpand  [args]					*:RustExpand*
379:RustExpand! [TYPE] [args]
380		Expands the current file using `--pretty` and displays the
381		results in a new split.  If the current file has unsaved
382		changes, it will be saved first using |:update|.  If the
383		current file is an unnamed buffer, it will be written to a
384		temporary file first.
385
386		The arguments given to |:RustExpand| will be passed to rustc.
387		This is largely intended for specifying various `--cfg`
388		configurations.
389
390		If ! is specified, the first argument is the expansion type to
391		pass to `rustc --pretty`.  Otherwise it will default to
392		"expanded".
393
394		If |g:rustc_path| is defined, it is used as the path to rustc.
395		Otherwise it is assumed rustc can be found in $PATH.
396
397:RustEmitIr [args]					*:RustEmitIr*
398		Compiles the current file to LLVM IR and displays the results
399		in a new split.  If the current file has unsaved changes, it
400		will be saved first using |:update|.  If the current file is an
401		unnamed buffer, it will be written to a temporary file first.
402
403		The arguments given to |:RustEmitIr| will be passed to rustc.
404
405		If |g:rustc_path| is defined, it is used as the path to rustc.
406		Otherwise it is assumed rustc can be found in $PATH.
407
408:RustEmitAsm [args]					*:RustEmitAsm*
409		Compiles the current file to assembly and displays the results
410		in a new split.  If the current file has unsaved changes, it
411		will be saved first using |:update|.  If the current file is an
412		unnamed buffer, it will be written to a temporary file first.
413
414		The arguments given to |:RustEmitAsm| will be passed to rustc.
415
416		If |g:rustc_path| is defined, it is used as the path to rustc.
417		Otherwise it is assumed rustc can be found in $PATH.
418
419Running test(s) ~
420
421:[N]RustTest[!] [options]				*:RustTest*
422		Runs a test under the cursor when the current buffer is in a
423		cargo project with "cargo test" command.  If the command did
424		not find any test function under the cursor, it stops with an
425		error message.
426
427		When N is given, adjust the size of the new window to N lines
428		or columns.
429
430		When ! is given, runs all tests regardless of current cursor
431		position.
432
433		When [options] is given, it is passed to "cargo" command
434		arguments.
435
436		When the current buffer is outside a cargo project, the
437		command runs "rustc --test" command instead of "cargo test" as
438		fallback.  All tests are run regardless of adding ! since
439		there is no way to run specific test function with rustc.
440		[options] is passed to "rustc" command arguments in that case.
441
442		Takes optional modifiers (see |<mods>|): >vim
443			:tab RustTest
444			:belowright 16RustTest
445			:leftabove vert 80RustTest
446<
447rust.vim Debugging ~
448
449:RustInfo						*:RustInfo*
450		Emits debugging info of the Vim Rust plugin.
451
452:RustInfoToClipboard					*:RustInfoClipboard*
453		Saves debugging info of the Vim Rust plugin to the default
454		register.
455
456:RustInfoToFile [filename]				*:RustInfoToFile*
457		Saves debugging info of the Vim Rust plugin to the given file,
458		overwriting it.
459
460==============================================================================
461MAPPINGS						*rust-mappings*
462
463This plugin defines Normal mode, Visual mode, and Operator-pending mode
464mappings for |[[| and |]]| to support hanging indents.
465
466 vim:tw=78:sw=4:noet:ts=8:ft=help:norl: