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