mirror of
https://github.com/amix/vimrc
synced 2025-07-10 03:25:00 +08:00
Updated plugins
This commit is contained in:
@ -3,7 +3,17 @@ function! cargo#Load()
|
||||
endfunction
|
||||
|
||||
function! cargo#cmd(args)
|
||||
execute "! cargo" a:args
|
||||
" Trim trailing spaces. This is necessary since :terminal command parses
|
||||
" trailing spaces as an empty argument.
|
||||
let args = substitute(a:args, '\s\+$', '', '')
|
||||
if has('terminal')
|
||||
let cmd = 'terminal'
|
||||
elseif has('nvim')
|
||||
let cmd = 'noautocmd new | terminal'
|
||||
else
|
||||
let cmd = '!'
|
||||
endif
|
||||
execute cmd 'cargo' args
|
||||
endfunction
|
||||
|
||||
function! s:nearest_cargo(...) abort
|
||||
|
@ -1,4 +1,3 @@
|
||||
" Author: Kevin Ballard
|
||||
" Description: Helper functions for Rust commands/mappings
|
||||
" Last Modified: May 27, 2014
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
@ -508,16 +507,23 @@ function! s:SearchTestFunctionNameUnderCursor() abort
|
||||
return matchstr(getline(test_func_line), '\m\C^\s*fn\s\+\zs\h\w*')
|
||||
endfunction
|
||||
|
||||
function! rust#Test(all, options) abort
|
||||
function! rust#Test(mods, winsize, all, options) abort
|
||||
let manifest = findfile('Cargo.toml', expand('%:p:h') . ';')
|
||||
if manifest ==# ''
|
||||
return rust#Run(1, '--test ' . a:options)
|
||||
endif
|
||||
|
||||
" <count> defaults to 0, but we prefer an empty string
|
||||
let winsize = a:winsize ? a:winsize : ''
|
||||
|
||||
if has('terminal')
|
||||
let cmd = 'terminal '
|
||||
if has('patch-8.0.910')
|
||||
let cmd = printf('%s noautocmd %snew | terminal ++curwin ', a:mods, winsize)
|
||||
else
|
||||
let cmd = printf('%s terminal ', a:mods)
|
||||
endif
|
||||
elseif has('nvim')
|
||||
let cmd = 'noautocmd new | terminal '
|
||||
let cmd = printf('%s noautocmd %snew | terminal ', a:mods, winsize)
|
||||
else
|
||||
let cmd = '!'
|
||||
let manifest = shellescape(manifest)
|
||||
|
@ -426,12 +426,15 @@ functionality from other plugins.
|
||||
Running test(s)
|
||||
---------------
|
||||
|
||||
:RustTest[!] [options] *:RustTest*
|
||||
:[N]RustTest[!] [options] *:RustTest*
|
||||
Runs a test under the cursor when the current buffer is in a
|
||||
cargo project with "cargo test" command. If the command did
|
||||
not find any test function under the cursor, it stops with an
|
||||
error message.
|
||||
|
||||
When N is given, adjust the size of the new window to N lines
|
||||
or columns.
|
||||
|
||||
When ! is given, runs all tests regardless of current cursor
|
||||
position.
|
||||
|
||||
@ -444,7 +447,11 @@ Running test(s)
|
||||
is no way to run specific test function with rustc. [options]
|
||||
is passed to "rustc" command arguments in the case.
|
||||
|
||||
|
||||
Takes optional modifiers (see |<mods>|): >
|
||||
:tab RustTest
|
||||
:belowright 16RustTest
|
||||
:leftabove vert 80RustTest
|
||||
<
|
||||
rust.vim Debugging
|
||||
------------------
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
" Language: Rust
|
||||
" Description: Vim ftplugin for Rust
|
||||
" Maintainer: Chris Morgan <me@chrismorgan.info>
|
||||
" Maintainer: Kevin Ballard <kevin@sb.org>
|
||||
" Last Change: June 08, 2016
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
|
||||
@ -137,7 +136,7 @@ command! -bar RustInfoToClipboard call rust#debugging#InfoToClipboard()
|
||||
command! -bar -nargs=1 RustInfoToFile call rust#debugging#InfoToFile(<f-args>)
|
||||
|
||||
" See |:RustTest| for docs
|
||||
command! -buffer -nargs=* -bang RustTest call rust#Test(<bang>0, <q-args>)
|
||||
command! -buffer -nargs=* -count -bang RustTest call rust#Test(<q-mods>, <count>, <bang>0, <q-args>)
|
||||
|
||||
if !exists("b:rust_last_rustc_args") || !exists("b:rust_last_args")
|
||||
let b:rust_last_rustc_args = []
|
||||
|
@ -191,7 +191,12 @@ function GetRustIndent(lnum)
|
||||
" A line that ends with '.<expr>;' is probably an end of a long list
|
||||
" of method operations.
|
||||
if prevline =~# '\V\^\s\*.' && l:last_prevline_character ==# ';'
|
||||
return indent(prevlinenum) - s:shiftwidth()
|
||||
call cursor(a:lnum - 1, 1)
|
||||
let l:scope_start = searchpair('{\|(', '', '}\|)', 'nbW',
|
||||
\ 's:is_string_comment(line("."), col("."))')
|
||||
if l:scope_start != 0 && l:scope_start < a:lnum
|
||||
return indent(l:scope_start) + 4
|
||||
endif
|
||||
endif
|
||||
|
||||
if l:last_prevline_character ==# ","
|
||||
|
@ -53,6 +53,7 @@ syn keyword rustKeyword mod trait nextgroup=rustIdentifier skipwhite skipe
|
||||
syn keyword rustStorage move mut ref static const
|
||||
syn match rustDefault /\<default\ze\_s\+\(impl\|fn\|type\|const\)\>/
|
||||
syn keyword rustAwait await
|
||||
syn match rustKeyword /\<try\>!\@!/ display
|
||||
|
||||
syn keyword rustPubScopeCrate crate contained
|
||||
syn match rustPubScopeDelim /[()]/ contained
|
||||
|
@ -225,6 +225,51 @@ Expect rust (issue #5):
|
||||
}
|
||||
}
|
||||
|
||||
############################################
|
||||
# Issue #366
|
||||
|
||||
Given rust:
|
||||
fn f() {
|
||||
g(|_| {
|
||||
h();
|
||||
})
|
||||
.unwrap();
|
||||
h();
|
||||
}
|
||||
|
||||
Do:
|
||||
vip=
|
||||
|
||||
Expect rust (issue #366):
|
||||
fn f() {
|
||||
g(|_| {
|
||||
h();
|
||||
})
|
||||
.unwrap();
|
||||
h();
|
||||
}
|
||||
|
||||
Given rust:
|
||||
fn f() {
|
||||
let a = g(|_| {
|
||||
h();
|
||||
})
|
||||
.unwrap();
|
||||
h();
|
||||
}
|
||||
|
||||
Do:
|
||||
vip=
|
||||
|
||||
Expect rust (issue #366, variation #2):
|
||||
fn f() {
|
||||
let a = g(|_| {
|
||||
h();
|
||||
})
|
||||
.unwrap();
|
||||
h();
|
||||
}
|
||||
|
||||
############################################
|
||||
|
||||
Given rust:
|
||||
|
Reference in New Issue
Block a user