1 *ft_rust.txt* Filetype plugin for Rust
3 ==============================================================================
6 1. Introduction |rust-intro|
7 2. Settings |rust-settings|
8 3. Commands |rust-commands|
9 4. Mappings |rust-mappings|
11 ==============================================================================
12 INTRODUCTION *rust-intro*
14 This plugin provides syntax and supporting functionality for the Rust
17 ==============================================================================
18 SETTINGS *rust-settings*
20 This plugin has a few variables you can define in your vimrc that change the
21 behavior of the plugin.
25 Set this option to the path to rustc for use in the |:RustRun| and
26 |:RustExpand| commands. If unset, "rustc" will be located in $PATH: >
27 let g:rustc_path = $HOME."/bin/rustc"
30 *g:rustc_makeprg_no_percent*
31 g:rustc_makeprg_no_percent~
32 Set this option to 1 to have 'makeprg' default to "rustc" instead of
34 let g:rustc_makeprg_no_percent = 1
39 Set this option to turn on the basic |conceal| support: >
40 let g:rust_conceal = 1
43 *g:rust_conceal_mod_path*
44 g:rust_conceal_mod_path~
45 Set this option to turn on |conceal| for the path connecting token
47 let g:rust_conceal_mod_path = 1
52 Set this option to turn on |conceal| for the "pub" token: >
53 let g:rust_conceal_pub = 1
56 *g:rust_recommended_style*
57 g:rust_recommended_style~
58 Set this option to enable vim indentation and textwidth settings to
59 conform to style conventions of the rust standard library (i.e. use 4
60 spaces for indents and sets 'textwidth' to 99). This option is enabled
61 by default. To disable it: >
62 let g:rust_recommended_style = 0
67 Set this option to turn on |folding|: >
72 1 Braced blocks are folded. All folds are open by
74 2 Braced blocks are folded. 'foldlevel' is left at the
75 global value (all folds are closed by default).
77 *g:rust_bang_comment_leader*
78 g:rust_bang_comment_leader~
79 Set this option to 1 to preserve the leader on multi-line doc comments
80 using the /*! syntax: >
81 let g:rust_bang_comment_leader = 1
84 *g:ftplugin_rust_source_path*
85 g:ftplugin_rust_source_path~
86 Set this option to a path that should be prepended to 'path' for Rust
88 let g:ftplugin_rust_source_path = $HOME.'/dev/rust'
93 Set this option to the name of the 'rustfmt' executable in your $PATH. If
94 not specified it defaults to 'rustfmt' : >
95 let g:rustfmt_command = 'rustfmt'
99 Set this option to 1 to run |:RustFmt| automatically when saving a
100 buffer. If not specified it defaults to 0 : >
101 let g:rustfmt_autosave = 0
103 *g:rustfmt_fail_silently*
104 g:rustfmt_fail_silently~
105 Set this option to 1 to prevent 'rustfmt' from populating the
106 |location-list| with errors. If not specified it defaults to 0: >
107 let g:rustfmt_fail_silently = 0
111 Set this option to a string of options to pass to 'rustfmt'. The
112 write-mode is already set to 'overwrite'. If not specified it
114 let g:rustfmt_options = ''
119 Set this option to override the url for the playpen to use: >
120 let g:rust_playpen_url = 'https://play.rust-lang.org/'
123 *g:rust_shortener_url*
124 g:rust_shortener_url~
125 Set this option to override the url for the url shortener: >
126 let g:rust_shortener_url = 'https://is.gd/'
130 ==============================================================================
131 COMMANDS *rust-commands*
133 :RustRun [args] *:RustRun*
134 :RustRun! [rustc-args] [--] [args]
135 Compiles and runs the current file. If it has unsaved changes,
136 it will be saved first using |:update|. If the current file is
137 an unnamed buffer, it will be written to a temporary file
138 first. The compiled binary is always placed in a temporary
139 directory, but is run from the current directory.
141 The arguments given to |:RustRun| will be passed to the
144 If ! is specified, the arguments are passed to rustc instead.
145 A "--" argument will separate the rustc arguments from the
146 arguments passed to the binary.
148 If |g:rustc_path| is defined, it is used as the path to rustc.
149 Otherwise it is assumed rustc can be found in $PATH.
151 :RustExpand [args] *:RustExpand*
152 :RustExpand! [TYPE] [args]
153 Expands the current file using --pretty and displays the
154 results in a new split. If the current file has unsaved
155 changes, it will be saved first using |:update|. If the
156 current file is an unnamed buffer, it will be written to a
157 temporary file first.
159 The arguments given to |:RustExpand| will be passed to rustc.
160 This is largely intended for specifying various --cfg
163 If ! is specified, the first argument is the expansion type to
164 pass to rustc --pretty. Otherwise it will default to
167 If |g:rustc_path| is defined, it is used as the path to rustc.
168 Otherwise it is assumed rustc can be found in $PATH.
170 :RustEmitIr [args] *:RustEmitIr*
171 Compiles the current file to LLVM IR and displays the results
172 in a new split. If the current file has unsaved changes, it
173 will be saved first using |:update|. If the current file is an
174 unnamed buffer, it will be written to a temporary file first.
176 The arguments given to |:RustEmitIr| will be passed to rustc.
178 If |g:rustc_path| is defined, it is used as the path to rustc.
179 Otherwise it is assumed rustc can be found in $PATH.
181 :RustEmitAsm [args] *:RustEmitAsm*
182 Compiles the current file to assembly and displays the results
183 in a new split. If the current file has unsaved changes, it
184 will be saved first using |:update|. If the current file is an
185 unnamed buffer, it will be written to a temporary file first.
187 The arguments given to |:RustEmitAsm| will be passed to rustc.
189 If |g:rustc_path| is defined, it is used as the path to rustc.
190 Otherwise it is assumed rustc can be found in $PATH.
192 :RustPlay *:RustPlay*
193 This command will only work if you have web-api.vim installed
194 (available at https://github.com/mattn/webapi-vim). It sends the
195 current selection, or if nothing is selected, the entirety of the
196 current buffer to the Rust playpen, and emits a message with the
197 shortened URL to the playpen.
199 |g:rust_playpen_url| is the base URL to the playpen, by default
200 "https://play.rust-lang.org/".
202 |g:rust_shortener_url| is the base url for the shorterner, by
203 default "https://is.gd/"
206 Runs |g:rustfmt_command| on the current buffer. If
207 |g:rustfmt_options| is set then those will be passed to the
210 If |g:rustfmt_fail_silently| is 0 (the default) then it
211 will populate the |location-list| with the errors from
212 |g:rustfmt_command|. If |g:rustfmt_fail_silently| is set to 1
213 then it will not populate the |location-list|.
215 :RustFmtRange *:RustFmtRange*
216 Runs |g:rustfmt_command| with selected range. See
217 |:RustFmt| for any other information.
219 ==============================================================================
220 MAPPINGS *rust-mappings*
222 This plugin defines mappings for |[[| and |]]| to support hanging indents.
224 It also has a few other mappings:
227 <D-r> Executes |:RustRun| with no arguments.
228 Note: This binding is only available in MacVim.
231 <D-R> Populates the command line with |:RustRun|! using the
232 arguments given to the last invocation, but does not
234 Note: This binding is only available in MacVim.
236 ==============================================================================
237 vim:tw=78:sw=4:noet:ts=8:ft=help:norl: