blob: 7fe7b7c4a6c9e49750a1d93d3c4cb050e4c2c550 [file] [log] [blame]
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +01001*ft_rust.txt* For Vim version 9.0. Last change: 2022 Oct 17
Bram Moolenaard2f3a8b2018-06-19 14:35:59 +02002
3This is documentation for the Rust filetype plugin.
Bram Moolenaar3c2881d2017-03-21 19:18:29 +01004
5==============================================================================
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +01006CONTENTS *rust*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +01007
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010081. Introduction |rust-intro|
92. Settings |rust-settings|
103. Commands |rust-commands|
114. Mappings |rust-mappings|
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010012
13==============================================================================
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010014INTRODUCTION *rust-intro*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010015
16This plugin provides syntax and supporting functionality for the Rust
17filetype.
18
19==============================================================================
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010020SETTINGS *rust-settings*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010021
22This plugin has a few variables you can define in your vimrc that change the
23behavior of the plugin.
24
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010025 *g:rustc_path*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010026g:rustc_path~
27 Set this option to the path to rustc for use in the |:RustRun| and
28 |:RustExpand| commands. If unset, "rustc" will be located in $PATH: >
Bram Moolenaarc51cf032022-02-26 12:25:45 +000029 let g:rustc_path = $HOME .. "/bin/rustc"
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010030<
31
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010032 *g:rustc_makeprg_no_percent*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010033g:rustc_makeprg_no_percent~
34 Set this option to 1 to have 'makeprg' default to "rustc" instead of
35 "rustc %": >
36 let g:rustc_makeprg_no_percent = 1
37<
38
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010039 *g:rust_conceal*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010040g:rust_conceal~
41 Set this option to turn on the basic |conceal| support: >
42 let g:rust_conceal = 1
43<
44
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010045 *g:rust_conceal_mod_path*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010046g:rust_conceal_mod_path~
47 Set this option to turn on |conceal| for the path connecting token
48 "::": >
49 let g:rust_conceal_mod_path = 1
50<
51
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010052 *g:rust_conceal_pub*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010053g:rust_conceal_pub~
54 Set this option to turn on |conceal| for the "pub" token: >
55 let g:rust_conceal_pub = 1
56<
57
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010058 *g:rust_recommended_style*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010059g:rust_recommended_style~
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010060 Set this option to enable vim indentation and textwidth settings to
61 conform to style conventions of the rust standard library (i.e. use 4
62 spaces for indents and sets 'textwidth' to 99). This option is enabled
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010063 by default. To disable it: >
64 let g:rust_recommended_style = 0
65<
66
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010067 *g:rust_fold*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010068g:rust_fold~
69 Set this option to turn on |folding|: >
70 let g:rust_fold = 1
71<
72 Value Effect ~
73 0 No folding
74 1 Braced blocks are folded. All folds are open by
75 default.
76 2 Braced blocks are folded. 'foldlevel' is left at the
77 global value (all folds are closed by default).
78
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010079 *g:rust_bang_comment_leader*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010080g:rust_bang_comment_leader~
81 Set this option to 1 to preserve the leader on multi-line doc comments
82 using the /*! syntax: >
83 let g:rust_bang_comment_leader = 1
84<
85
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010086 *g:ftplugin_rust_source_path*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010087g:ftplugin_rust_source_path~
88 Set this option to a path that should be prepended to 'path' for Rust
89 source files: >
Bram Moolenaarc51cf032022-02-26 12:25:45 +000090 let g:ftplugin_rust_source_path = $HOME .. '/dev/rust'
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010091<
92
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010093 *g:rustfmt_command*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010094g:rustfmt_command~
95 Set this option to the name of the 'rustfmt' executable in your $PATH. If
96 not specified it defaults to 'rustfmt' : >
97 let g:rustfmt_command = 'rustfmt'
98<
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +010099 *g:rustfmt_autosave*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100100g:rustfmt_autosave~
101 Set this option to 1 to run |:RustFmt| automatically when saving a
102 buffer. If not specified it defaults to 0 : >
103 let g:rustfmt_autosave = 0
104<
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100105 *g:rustfmt_fail_silently*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100106g:rustfmt_fail_silently~
107 Set this option to 1 to prevent 'rustfmt' from populating the
108 |location-list| with errors. If not specified it defaults to 0: >
109 let g:rustfmt_fail_silently = 0
110<
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100111 *g:rustfmt_options*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100112g:rustfmt_options~
113 Set this option to a string of options to pass to 'rustfmt'. The
114 write-mode is already set to 'overwrite'. If not specified it
115 defaults to '' : >
116 let g:rustfmt_options = ''
117<
118
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100119 *g:rust_playpen_url*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100120g:rust_playpen_url~
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200121 Set this option to override the URL for the playpen to use: >
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100122 let g:rust_playpen_url = 'https://play.rust-lang.org/'
123<
124
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100125 *g:rust_shortener_url*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100126g:rust_shortener_url~
Bram Moolenaarf55e4c82017-08-01 20:44:53 +0200127 Set this option to override the URL for the URL shortener: >
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100128 let g:rust_shortener_url = 'https://is.gd/'
129<
130
131
132==============================================================================
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100133COMMANDS *rust-commands*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100134
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100135:RustRun [args] *:RustRun*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100136:RustRun! [rustc-args] [--] [args]
137 Compiles and runs the current file. If it has unsaved changes,
138 it will be saved first using |:update|. If the current file is
139 an unnamed buffer, it will be written to a temporary file
140 first. The compiled binary is always placed in a temporary
141 directory, but is run from the current directory.
142
143 The arguments given to |:RustRun| will be passed to the
144 compiled binary.
145
146 If ! is specified, the arguments are passed to rustc instead.
147 A "--" argument will separate the rustc arguments from the
148 arguments passed to the binary.
149
150 If |g:rustc_path| is defined, it is used as the path to rustc.
151 Otherwise it is assumed rustc can be found in $PATH.
152
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100153:RustExpand [args] *:RustExpand*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100154:RustExpand! [TYPE] [args]
155 Expands the current file using --pretty and displays the
156 results in a new split. If the current file has unsaved
157 changes, it will be saved first using |:update|. If the
158 current file is an unnamed buffer, it will be written to a
159 temporary file first.
160
161 The arguments given to |:RustExpand| will be passed to rustc.
162 This is largely intended for specifying various --cfg
163 configurations.
164
165 If ! is specified, the first argument is the expansion type to
166 pass to rustc --pretty. Otherwise it will default to
167 "expanded".
168
169 If |g:rustc_path| is defined, it is used as the path to rustc.
170 Otherwise it is assumed rustc can be found in $PATH.
171
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100172:RustEmitIr [args] *:RustEmitIr*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100173 Compiles the current file to LLVM IR and displays the results
174 in a new split. If the current file has unsaved changes, it
175 will be saved first using |:update|. If the current file is an
176 unnamed buffer, it will be written to a temporary file first.
177
178 The arguments given to |:RustEmitIr| will be passed to rustc.
179
180 If |g:rustc_path| is defined, it is used as the path to rustc.
181 Otherwise it is assumed rustc can be found in $PATH.
182
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100183:RustEmitAsm [args] *:RustEmitAsm*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100184 Compiles the current file to assembly and displays the results
185 in a new split. If the current file has unsaved changes, it
186 will be saved first using |:update|. If the current file is an
187 unnamed buffer, it will be written to a temporary file first.
188
189 The arguments given to |:RustEmitAsm| will be passed to rustc.
190
191 If |g:rustc_path| is defined, it is used as the path to rustc.
192 Otherwise it is assumed rustc can be found in $PATH.
193
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100194:RustPlay *:RustPlay*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100195 This command will only work if you have web-api.vim installed
196 (available at https://github.com/mattn/webapi-vim). It sends the
197 current selection, or if nothing is selected, the entirety of the
198 current buffer to the Rust playpen, and emits a message with the
199 shortened URL to the playpen.
200
201 |g:rust_playpen_url| is the base URL to the playpen, by default
202 "https://play.rust-lang.org/".
203
Bram Moolenaar01164a62017-11-02 22:58:42 +0100204 |g:rust_shortener_url| is the base URL for the shortener, by
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100205 default "https://is.gd/"
206
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100207:RustFmt *:RustFmt*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100208 Runs |g:rustfmt_command| on the current buffer. If
209 |g:rustfmt_options| is set then those will be passed to the
210 executable.
211
212 If |g:rustfmt_fail_silently| is 0 (the default) then it
213 will populate the |location-list| with the errors from
214 |g:rustfmt_command|. If |g:rustfmt_fail_silently| is set to 1
215 then it will not populate the |location-list|.
216
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100217:RustFmtRange *:RustFmtRange*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100218 Runs |g:rustfmt_command| with selected range. See
219 |:RustFmt| for any other information.
220
221==============================================================================
Bram Moolenaar6ebe4f92022-10-28 20:47:54 +0100222MAPPINGS *rust-mappings*
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100223
224This plugin defines mappings for |[[| and |]]| to support hanging indents.
225
226It also has a few other mappings:
227
228 *rust_<D-r>*
229<D-r> Executes |:RustRun| with no arguments.
230 Note: This binding is only available in MacVim.
231
232 *rust_<D-R>*
233<D-R> Populates the command line with |:RustRun|! using the
234 arguments given to the last invocation, but does not
235 execute it.
236 Note: This binding is only available in MacVim.
237
238==============================================================================
Bram Moolenaard473c8c2018-08-11 18:00:22 +0200239 vim:tw=78:sw=4:ts=8:noet:ft=help:norl: