ft_rust.txt 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. *ft_rust.txt* For Vim version 8.1. Last change: 2017 Nov 02
  2. This is documentation for the Rust filetype plugin.
  3. ==============================================================================
  4. CONTENTS *rust*
  5. 1. Introduction |rust-intro|
  6. 2. Settings |rust-settings|
  7. 3. Commands |rust-commands|
  8. 4. Mappings |rust-mappings|
  9. ==============================================================================
  10. INTRODUCTION *rust-intro*
  11. This plugin provides syntax and supporting functionality for the Rust
  12. filetype.
  13. ==============================================================================
  14. SETTINGS *rust-settings*
  15. This plugin has a few variables you can define in your vimrc that change the
  16. behavior of the plugin.
  17. *g:rustc_path*
  18. g:rustc_path~
  19. Set this option to the path to rustc for use in the |:RustRun| and
  20. |:RustExpand| commands. If unset, "rustc" will be located in $PATH: >
  21. let g:rustc_path = $HOME .. "/bin/rustc"
  22. <
  23. *g:rustc_makeprg_no_percent*
  24. g:rustc_makeprg_no_percent~
  25. Set this option to 1 to have 'makeprg' default to "rustc" instead of
  26. "rustc %": >
  27. let g:rustc_makeprg_no_percent = 1
  28. <
  29. *g:rust_conceal*
  30. g:rust_conceal~
  31. Set this option to turn on the basic |conceal| support: >
  32. let g:rust_conceal = 1
  33. <
  34. *g:rust_conceal_mod_path*
  35. g:rust_conceal_mod_path~
  36. Set this option to turn on |conceal| for the path connecting token
  37. "::": >
  38. let g:rust_conceal_mod_path = 1
  39. <
  40. *g:rust_conceal_pub*
  41. g:rust_conceal_pub~
  42. Set this option to turn on |conceal| for the "pub" token: >
  43. let g:rust_conceal_pub = 1
  44. <
  45. *g:rust_recommended_style*
  46. g:rust_recommended_style~
  47. Set this option to enable vim indentation and textwidth settings to
  48. conform to style conventions of the rust standard library (i.e. use 4
  49. spaces for indents and sets 'textwidth' to 99). This option is enabled
  50. by default. To disable it: >
  51. let g:rust_recommended_style = 0
  52. <
  53. *g:rust_fold*
  54. g:rust_fold~
  55. Set this option to turn on |folding|: >
  56. let g:rust_fold = 1
  57. <
  58. Value Effect ~
  59. 0 No folding
  60. 1 Braced blocks are folded. All folds are open by
  61. default.
  62. 2 Braced blocks are folded. 'foldlevel' is left at the
  63. global value (all folds are closed by default).
  64. *g:rust_bang_comment_leader*
  65. g:rust_bang_comment_leader~
  66. Set this option to 1 to preserve the leader on multi-line doc comments
  67. using the /*! syntax: >
  68. let g:rust_bang_comment_leader = 1
  69. <
  70. *g:ftplugin_rust_source_path*
  71. g:ftplugin_rust_source_path~
  72. Set this option to a path that should be prepended to 'path' for Rust
  73. source files: >
  74. let g:ftplugin_rust_source_path = $HOME .. '/dev/rust'
  75. <
  76. *g:rustfmt_command*
  77. g:rustfmt_command~
  78. Set this option to the name of the "rustfmt" executable in your $PATH. If
  79. not specified it defaults to "rustfmt" : >
  80. let g:rustfmt_command = 'rustfmt'
  81. <
  82. *g:rustfmt_autosave*
  83. g:rustfmt_autosave~
  84. Set this option to 1 to run |:RustFmt| automatically when saving a
  85. buffer. If not specified it defaults to 0 : >
  86. let g:rustfmt_autosave = 0
  87. <
  88. *g:rustfmt_fail_silently*
  89. g:rustfmt_fail_silently~
  90. Set this option to 1 to prevent "rustfmt" from populating the
  91. |location-list| with errors. If not specified it defaults to 0: >
  92. let g:rustfmt_fail_silently = 0
  93. <
  94. *g:rustfmt_options*
  95. g:rustfmt_options~
  96. Set this option to a string of options to pass to "rustfmt". The
  97. write-mode is already set to "overwrite". If not specified it
  98. defaults to '' : >
  99. let g:rustfmt_options = ''
  100. <
  101. *g:rust_playpen_url*
  102. g:rust_playpen_url~
  103. Set this option to override the URL for the playpen to use: >
  104. let g:rust_playpen_url = 'https://play.rust-lang.org/'
  105. <
  106. *g:rust_shortener_url*
  107. g:rust_shortener_url~
  108. Set this option to override the URL for the URL shortener: >
  109. let g:rust_shortener_url = 'https://is.gd/'
  110. <
  111. ==============================================================================
  112. COMMANDS *rust-commands*
  113. :RustRun [args] *:RustRun*
  114. :RustRun! [rustc-args] [--] [args]
  115. Compiles and runs the current file. If it has unsaved changes,
  116. it will be saved first using |:update|. If the current file is
  117. an unnamed buffer, it will be written to a temporary file
  118. first. The compiled binary is always placed in a temporary
  119. directory, but is run from the current directory.
  120. The arguments given to |:RustRun| will be passed to the
  121. compiled binary.
  122. If ! is specified, the arguments are passed to rustc instead.
  123. A "--" argument will separate the rustc arguments from the
  124. arguments passed to the binary.
  125. If |g:rustc_path| is defined, it is used as the path to rustc.
  126. Otherwise it is assumed rustc can be found in $PATH.
  127. :RustExpand [args] *:RustExpand*
  128. :RustExpand! [TYPE] [args]
  129. Expands the current file using --pretty and displays the
  130. results in a new split. If the current file has unsaved
  131. changes, it will be saved first using |:update|. If the
  132. current file is an unnamed buffer, it will be written to a
  133. temporary file first.
  134. The arguments given to |:RustExpand| will be passed to rustc.
  135. This is largely intended for specifying various --cfg
  136. configurations.
  137. If ! is specified, the first argument is the expansion type to
  138. pass to rustc --pretty. Otherwise it will default to
  139. "expanded".
  140. If |g:rustc_path| is defined, it is used as the path to rustc.
  141. Otherwise it is assumed rustc can be found in $PATH.
  142. :RustEmitIr [args] *:RustEmitIr*
  143. Compiles the current file to LLVM IR and displays the results
  144. in a new split. If the current file has unsaved changes, it
  145. will be saved first using |:update|. If the current file is an
  146. unnamed buffer, it will be written to a temporary file first.
  147. The arguments given to |:RustEmitIr| will be passed to rustc.
  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. :RustEmitAsm [args] *:RustEmitAsm*
  151. Compiles the current file to assembly and displays the results
  152. in a new split. If the current file has unsaved changes, it
  153. will be saved first using |:update|. If the current file is an
  154. unnamed buffer, it will be written to a temporary file first.
  155. The arguments given to |:RustEmitAsm| will be passed to rustc.
  156. If |g:rustc_path| is defined, it is used as the path to rustc.
  157. Otherwise it is assumed rustc can be found in $PATH.
  158. :RustPlay *:RustPlay*
  159. This command will only work if you have web-api.vim installed
  160. (available at https://github.com/mattn/webapi-vim). It sends the
  161. current selection, or if nothing is selected, the entirety of the
  162. current buffer to the Rust playpen, and emits a message with the
  163. shortened URL to the playpen.
  164. |g:rust_playpen_url| is the base URL to the playpen, by default
  165. "https://play.rust-lang.org/".
  166. |g:rust_shortener_url| is the base URL for the shortener, by
  167. default "https://is.gd/"
  168. :RustFmt *:RustFmt*
  169. Runs |g:rustfmt_command| on the current buffer. If
  170. |g:rustfmt_options| is set then those will be passed to the
  171. executable.
  172. If |g:rustfmt_fail_silently| is 0 (the default) then it
  173. will populate the |location-list| with the errors from
  174. |g:rustfmt_command|. If |g:rustfmt_fail_silently| is set to 1
  175. then it will not populate the |location-list|.
  176. :RustFmtRange *:RustFmtRange*
  177. Runs |g:rustfmt_command| with selected range. See
  178. |:RustFmt| for any other information.
  179. ==============================================================================
  180. MAPPINGS *rust-mappings*
  181. This plugin defines mappings for |[[| and |]]| to support hanging indents.
  182. It also has a few other mappings:
  183. *rust_<D-r>*
  184. <D-r> Executes |:RustRun| with no arguments.
  185. Note: This binding is only available in MacVim.
  186. *rust_<D-R>*
  187. <D-R> Populates the command line with |:RustRun|! using the
  188. arguments given to the last invocation, but does not
  189. execute it.
  190. Note: This binding is only available in MacVim.
  191. ==============================================================================
  192. vim:tw=78:sw=4:ts=8:noet:ft=help:norl: