mirror of
https://github.com/amix/vimrc
synced 2025-07-10 03:25:00 +08:00
Updated plugins
This commit is contained in:
@ -8,28 +8,53 @@ Some things may not work on earlier versions.
|
||||
|
||||
## Installation
|
||||
|
||||
Use one of the following package managers:
|
||||
For activating the full functionality, this plugin requires either the plugin
|
||||
manager or the `.vimrc` to have the following:
|
||||
|
||||
* [Vim8 packages][vim8pack]:
|
||||
* `git clone https://github.com/rust-lang/rust.vim ~/.vim/pack/plugins/start/rust.vim`
|
||||
* [Vundle][v]:
|
||||
* Add `Plugin 'rust-lang/rust.vim'` to `~/.vimrc`
|
||||
* `:PluginInstall` or `$ vim +PluginInstall +qall`
|
||||
* *Note:* Vundle will not automatically detect Rust files properly if `filetype
|
||||
on` is executed before Vundle. Please check the [quickstart][vqs] for more
|
||||
details. Errors such as `Not an editor command: RustFmt` may occur if Vundle
|
||||
is misconfigured with this plugin.
|
||||
* [Pathogen][p]:
|
||||
* `git clone --depth=1 https://github.com/rust-lang/rust.vim.git ~/.vim/bundle/rust.vim`
|
||||
* [vim-plug][vp]:
|
||||
* Add `Plug 'rust-lang/rust.vim'` to `~/.vimrc`
|
||||
* `:PlugInstall` or `$ vim +PlugInstall +qall`
|
||||
* [dein.vim][d]:
|
||||
* Add `call dein#add('rust-lang/rust.vim')` to `~/.vimrc`
|
||||
* `:call dein#install()`
|
||||
* [NeoBundle][nb]:
|
||||
* Add `NeoBundle 'rust-lang/rust.vim'` to `~/.vimrc`
|
||||
* Re-open vim or execute `:source ~/.vimrc`
|
||||
```vim
|
||||
syntax enable
|
||||
filetype plugin indent on
|
||||
```
|
||||
|
||||
Most plugin managers don't do this automatically, so these statements are
|
||||
usually added by users in their `vimrc` _right after_ the plugin manager load
|
||||
section.
|
||||
|
||||
### [Vim8 packages][vim8pack]
|
||||
|
||||
```sh
|
||||
git clone https://github.com/rust-lang/rust.vim ~/.vim/pack/plugins/start/rust.vim
|
||||
```
|
||||
|
||||
### [Vundle][v]
|
||||
|
||||
```vim
|
||||
Plugin 'rust-lang/rust.vim'
|
||||
```
|
||||
|
||||
### [Pathogen][p]
|
||||
|
||||
```sh
|
||||
git clone --depth=1 https://github.com/rust-lang/rust.vim.git ~/.vim/bundle/rust.vim
|
||||
```
|
||||
|
||||
### [vim-plug][vp]
|
||||
|
||||
```vim
|
||||
Plug 'rust-lang/rust.vim'
|
||||
```
|
||||
|
||||
### [dein.vim][d]
|
||||
|
||||
```vim
|
||||
call dein#add('rust-lang/rust.vim')
|
||||
```
|
||||
|
||||
### [NeoBundle][nb]
|
||||
|
||||
```vim
|
||||
NeoBundle 'rust-lang/rust.vim'
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
@ -48,7 +73,8 @@ configure Tagbar to some degree.
|
||||
### Formatting with [rustfmt][rfmt]
|
||||
|
||||
The `:RustFmt` command will format your code with
|
||||
[rustfmt][rfmt] if installed.
|
||||
[rustfmt][rfmt] if installed. `rustfmt` can be installed
|
||||
via `rustup component add rustfmt`.
|
||||
|
||||
Placing `let g:rustfmt_autosave = 1` in your `~/.vimrc` will
|
||||
enable automatic running of `:RustFmt` when you save a buffer.
|
||||
@ -67,16 +93,16 @@ If you set g:rust_clip_command RustPlay will copy the url to the clipboard.
|
||||
|
||||
- Mac:
|
||||
|
||||
let g:rust_clip_command = 'pbcopy'
|
||||
let g:rust_clip_command = 'pbcopy'
|
||||
|
||||
- Linux:
|
||||
|
||||
let g:rust_clip_command = 'xclip -selection clipboard'
|
||||
let g:rust_clip_command = 'xclip -selection clipboard'
|
||||
|
||||
### Running a test under cursor
|
||||
|
||||
In cargo project, the `:RustTest` command will run a test under the cursor.
|
||||
This is useful when your project is bigger and running all tests take longer time.
|
||||
In a Cargo project, the `:RustTest` command will run the test that is under the cursor.
|
||||
This is useful when your project is big and running all of the tests takes a long time.
|
||||
|
||||
## Help
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
function! cargo#quickfix#CmdPre() abort
|
||||
if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo'
|
||||
if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo' &&
|
||||
\ &makeprg =~ '\V\^cargo\ \.\*'
|
||||
" Preserve the current directory, and 'lcd' to the nearest Cargo file.
|
||||
let b:rust_compiler_cargo_qf_has_lcd = haslocaldir()
|
||||
let b:rust_compiler_cargo_qf_prev_cd = getcwd()
|
||||
|
@ -63,12 +63,12 @@ endfunction
|
||||
function! s:RustfmtConfigOptions()
|
||||
let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';')
|
||||
if l:rustfmt_toml !=# ''
|
||||
return '--config-path '.fnamemodify(l:rustfmt_toml, ":p")
|
||||
return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p"))
|
||||
endif
|
||||
|
||||
let l:_rustfmt_toml = findfile('.rustfmt.toml', expand('%:p:h') . ';')
|
||||
if l:_rustfmt_toml !=# ''
|
||||
return '--config-path '.fnamemodify(l:_rustfmt_toml, ":p")
|
||||
return '--config-path '.shellescape(fnamemodify(l:_rustfmt_toml, ":p"))
|
||||
endif
|
||||
|
||||
" Default to edition 2018 in case no rustfmt.toml was found.
|
||||
@ -107,7 +107,7 @@ function! s:DeleteLines(start, end) abort
|
||||
endfunction
|
||||
|
||||
function! s:RunRustfmt(command, tmpname, from_writepre)
|
||||
mkview!
|
||||
let l:view = winsaveview()
|
||||
|
||||
let l:stderr_tmpname = tempname()
|
||||
call writefile([], l:stderr_tmpname)
|
||||
@ -213,7 +213,7 @@ function! s:RunRustfmt(command, tmpname, from_writepre)
|
||||
lwindow
|
||||
endif
|
||||
|
||||
silent! loadview
|
||||
call winrestview(l:view)
|
||||
endfunction
|
||||
|
||||
function! rustfmt#FormatRange(line1, line2)
|
||||
|
@ -65,10 +65,11 @@ syn match rustExternCrateString /".*"\_s*as/ contained nextgroup=rustIdentifie
|
||||
syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty
|
||||
|
||||
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
|
||||
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
|
||||
syn match rustFuncName "\%(r#\)\=\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
|
||||
|
||||
syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end="),\=[*+]" contains=TOP
|
||||
syn match rustMacroVariable "$\w\+"
|
||||
syn match rustRawIdent "\<r#\h\w*" contains=NONE
|
||||
|
||||
" Reserved (but not yet used) keywords {{{2
|
||||
syn keyword rustReservedKeyword become do priv typeof unsized abstract virtual final override
|
||||
@ -228,7 +229,7 @@ syn region rustCommentBlockDocNestError matchgroup=rustCommentBlockDocError star
|
||||
" then you must deal with cases like ``/*/**/*/``. And don't try making it
|
||||
" worse with ``\%(/\@<!\*\)\@<!``, either...
|
||||
|
||||
syn keyword rustTodo contained TODO FIXME XXX NB NOTE
|
||||
syn keyword rustTodo contained TODO FIXME XXX NB NOTE SAFETY
|
||||
|
||||
" asm! macro {{{2
|
||||
syn region rustAsmMacro matchgroup=rustMacro start="\<asm!\s*(" end=")" contains=rustAsmDirSpec,rustAsmSym,rustAsmConst,rustAsmOptionsGroup,rustComment.*,rustString.*
|
||||
|
Reference in New Issue
Block a user