1*ft_rust.txt* For Vim version 8.2. Last change: 2017 Nov 02 2 3This is documentation for the Rust filetype plugin. 4 5============================================================================== 6CONTENTS *rust* 7 81. Introduction |rust-intro| 92. Settings |rust-settings| 103. Commands |rust-commands| 114. Mappings |rust-mappings| 12 13============================================================================== 14INTRODUCTION *rust-intro* 15 16This plugin provides syntax and supporting functionality for the Rust 17filetype. 18 19============================================================================== 20SETTINGS *rust-settings* 21 22This plugin has a few variables you can define in your vimrc that change the 23behavior of the plugin. 24 25 *g:rustc_path* 26g: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: > 29 let g:rustc_path = $HOME."/bin/rustc" 30< 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 %": > 36 let g:rustc_makeprg_no_percent = 1 37< 38 39 *g:rust_conceal* 40g:rust_conceal~ 41 Set this option to turn on the basic |conceal| support: > 42 let g:rust_conceal = 1 43< 44 45 *g:rust_conceal_mod_path* 46g: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 52 *g:rust_conceal_pub* 53g:rust_conceal_pub~ 54 Set this option to turn on |conceal| for the "pub" token: > 55 let g:rust_conceal_pub = 1 56< 57 58 *g:rust_recommended_style* 59g:rust_recommended_style~ 60 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 63 by default. To disable it: > 64 let g:rust_recommended_style = 0 65< 66 67 *g:rust_fold* 68g: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 79 *g:rust_bang_comment_leader* 80g: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 86 *g:ftplugin_rust_source_path* 87g:ftplugin_rust_source_path~ 88 Set this option to a path that should be prepended to 'path' for Rust 89 source files: > 90 let g:ftplugin_rust_source_path = $HOME.'/dev/rust' 91< 92 93 *g:rustfmt_command* 94g: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< 99 *g:rustfmt_autosave* 100g: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< 105 *g:rustfmt_fail_silently* 106g: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< 111 *g:rustfmt_options* 112g: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 119 *g:rust_playpen_url* 120g:rust_playpen_url~ 121 Set this option to override the URL for the playpen to use: > 122 let g:rust_playpen_url = 'https://play.rust-lang.org/' 123< 124 125 *g:rust_shortener_url* 126g:rust_shortener_url~ 127 Set this option to override the URL for the URL shortener: > 128 let g:rust_shortener_url = 'https://is.gd/' 129< 130 131 132============================================================================== 133COMMANDS *rust-commands* 134 135:RustRun [args] *:RustRun* 136: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 153:RustExpand [args] *:RustExpand* 154: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 172:RustEmitIr [args] *:RustEmitIr* 173 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 183:RustEmitAsm [args] *:RustEmitAsm* 184 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 194:RustPlay *:RustPlay* 195 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 204 |g:rust_shortener_url| is the base URL for the shortener, by 205 default "https://is.gd/" 206 207:RustFmt *:RustFmt* 208 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 217:RustFmtRange *:RustFmtRange* 218 Runs |g:rustfmt_command| with selected range. See 219 |:RustFmt| for any other information. 220 221============================================================================== 222MAPPINGS *rust-mappings* 223 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============================================================================== 239 vim:tw=78:sw=4:ts=8:noet:ft=help:norl: 240