Bram Moolenaar | 3c2881d | 2017-03-21 19:18:29 +0100 | [diff] [blame] | 1 | *ft_rust.txt* Filetype plugin for Rust |
| 2 | |
| 3 | ============================================================================== |
Bram Moolenaar | e0720cb | 2017-03-29 13:48:40 +0200 | [diff] [blame] | 4 | CONTENTS *rust* |
Bram Moolenaar | 3c2881d | 2017-03-21 19:18:29 +0100 | [diff] [blame] | 5 | |
| 6 | 1. Introduction |rust-intro| |
| 7 | 2. Settings |rust-settings| |
| 8 | 3. Commands |rust-commands| |
| 9 | 4. Mappings |rust-mappings| |
| 10 | |
| 11 | ============================================================================== |
| 12 | INTRODUCTION *rust-intro* |
| 13 | |
| 14 | This plugin provides syntax and supporting functionality for the Rust |
| 15 | filetype. |
| 16 | |
| 17 | ============================================================================== |
| 18 | SETTINGS *rust-settings* |
| 19 | |
| 20 | This plugin has a few variables you can define in your vimrc that change the |
| 21 | behavior of the plugin. |
| 22 | |
| 23 | *g:rustc_path* |
| 24 | g:rustc_path~ |
| 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" |
| 28 | < |
| 29 | |
| 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 |
| 33 | "rustc %": > |
| 34 | let g:rustc_makeprg_no_percent = 1 |
| 35 | < |
| 36 | |
| 37 | *g:rust_conceal* |
| 38 | g:rust_conceal~ |
| 39 | Set this option to turn on the basic |conceal| support: > |
| 40 | let g:rust_conceal = 1 |
| 41 | < |
| 42 | |
| 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 |
| 46 | "::": > |
| 47 | let g:rust_conceal_mod_path = 1 |
| 48 | < |
| 49 | |
| 50 | *g:rust_conceal_pub* |
| 51 | g:rust_conceal_pub~ |
| 52 | Set this option to turn on |conceal| for the "pub" token: > |
| 53 | let g:rust_conceal_pub = 1 |
| 54 | < |
| 55 | |
| 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 |
| 63 | < |
| 64 | |
| 65 | *g:rust_fold* |
| 66 | g:rust_fold~ |
| 67 | Set this option to turn on |folding|: > |
| 68 | let g:rust_fold = 1 |
| 69 | < |
| 70 | Value Effect ~ |
| 71 | 0 No folding |
| 72 | 1 Braced blocks are folded. All folds are open by |
| 73 | default. |
| 74 | 2 Braced blocks are folded. 'foldlevel' is left at the |
| 75 | global value (all folds are closed by default). |
| 76 | |
| 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 |
| 82 | < |
| 83 | |
| 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 |
| 87 | source files: > |
| 88 | let g:ftplugin_rust_source_path = $HOME.'/dev/rust' |
| 89 | < |
| 90 | |
| 91 | *g:rustfmt_command* |
| 92 | g:rustfmt_command~ |
| 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' |
| 96 | < |
| 97 | *g:rustfmt_autosave* |
| 98 | g:rustfmt_autosave~ |
| 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 |
| 102 | < |
| 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 |
| 108 | < |
| 109 | *g:rustfmt_options* |
| 110 | g:rustfmt_options~ |
| 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 |
| 113 | defaults to '' : > |
| 114 | let g:rustfmt_options = '' |
| 115 | < |
| 116 | |
| 117 | *g:rust_playpen_url* |
| 118 | g:rust_playpen_url~ |
Bram Moolenaar | f55e4c8 | 2017-08-01 20:44:53 +0200 | [diff] [blame] | 119 | Set this option to override the URL for the playpen to use: > |
Bram Moolenaar | 3c2881d | 2017-03-21 19:18:29 +0100 | [diff] [blame] | 120 | let g:rust_playpen_url = 'https://play.rust-lang.org/' |
| 121 | < |
| 122 | |
| 123 | *g:rust_shortener_url* |
| 124 | g:rust_shortener_url~ |
Bram Moolenaar | f55e4c8 | 2017-08-01 20:44:53 +0200 | [diff] [blame] | 125 | Set this option to override the URL for the URL shortener: > |
Bram Moolenaar | 3c2881d | 2017-03-21 19:18:29 +0100 | [diff] [blame] | 126 | let g:rust_shortener_url = 'https://is.gd/' |
| 127 | < |
| 128 | |
| 129 | |
| 130 | ============================================================================== |
| 131 | COMMANDS *rust-commands* |
| 132 | |
| 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. |
| 140 | |
| 141 | The arguments given to |:RustRun| will be passed to the |
| 142 | compiled binary. |
| 143 | |
| 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. |
| 147 | |
| 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. |
| 150 | |
| 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. |
| 158 | |
| 159 | The arguments given to |:RustExpand| will be passed to rustc. |
| 160 | This is largely intended for specifying various --cfg |
| 161 | configurations. |
| 162 | |
| 163 | If ! is specified, the first argument is the expansion type to |
| 164 | pass to rustc --pretty. Otherwise it will default to |
| 165 | "expanded". |
| 166 | |
| 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. |
| 169 | |
| 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. |
| 175 | |
| 176 | The arguments given to |:RustEmitIr| will be passed to rustc. |
| 177 | |
| 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. |
| 180 | |
| 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. |
| 186 | |
| 187 | The arguments given to |:RustEmitAsm| will be passed to rustc. |
| 188 | |
| 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. |
| 191 | |
| 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. |
| 198 | |
| 199 | |g:rust_playpen_url| is the base URL to the playpen, by default |
| 200 | "https://play.rust-lang.org/". |
| 201 | |
Bram Moolenaar | f55e4c8 | 2017-08-01 20:44:53 +0200 | [diff] [blame] | 202 | |g:rust_shortener_url| is the base URL for the shorterner, by |
Bram Moolenaar | 3c2881d | 2017-03-21 19:18:29 +0100 | [diff] [blame] | 203 | default "https://is.gd/" |
| 204 | |
| 205 | :RustFmt *:RustFmt* |
| 206 | Runs |g:rustfmt_command| on the current buffer. If |
| 207 | |g:rustfmt_options| is set then those will be passed to the |
| 208 | executable. |
| 209 | |
| 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|. |
| 214 | |
| 215 | :RustFmtRange *:RustFmtRange* |
| 216 | Runs |g:rustfmt_command| with selected range. See |
| 217 | |:RustFmt| for any other information. |
| 218 | |
| 219 | ============================================================================== |
| 220 | MAPPINGS *rust-mappings* |
| 221 | |
| 222 | This plugin defines mappings for |[[| and |]]| to support hanging indents. |
| 223 | |
| 224 | It also has a few other mappings: |
| 225 | |
| 226 | *rust_<D-r>* |
| 227 | <D-r> Executes |:RustRun| with no arguments. |
| 228 | Note: This binding is only available in MacVim. |
| 229 | |
| 230 | *rust_<D-R>* |
| 231 | <D-R> Populates the command line with |:RustRun|! using the |
| 232 | arguments given to the last invocation, but does not |
| 233 | execute it. |
| 234 | Note: This binding is only available in MacVim. |
| 235 | |
| 236 | ============================================================================== |
| 237 | vim:tw=78:sw=4:noet:ts=8:ft=help:norl: |