Skip to content

Commit 323ed1e

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents f4dd707 + b2964f2 commit 323ed1e

File tree

22 files changed

+1779
-146
lines changed

22 files changed

+1779
-146
lines changed

runtime/autoload/rust.vim

Lines changed: 415 additions & 0 deletions
Large diffs are not rendered by default.

runtime/autoload/rustfmt.vim

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
" Author: Stephen Sugden <[email protected]>
2+
"
3+
" Adapted from https://github.com/fatih/vim-go
4+
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
5+
6+
if !exists("g:rustfmt_autosave")
7+
let g:rustfmt_autosave = 0
8+
endif
9+
10+
if !exists("g:rustfmt_command")
11+
let g:rustfmt_command = "rustfmt"
12+
endif
13+
14+
if !exists("g:rustfmt_options")
15+
let g:rustfmt_options = ""
16+
endif
17+
18+
if !exists("g:rustfmt_fail_silently")
19+
let g:rustfmt_fail_silently = 0
20+
endif
21+
22+
let s:got_fmt_error = 0
23+
24+
function! s:RustfmtCommandRange(filename, line1, line2)
25+
let l:arg = {"file": shellescape(a:filename), "range": [a:line1, a:line2]}
26+
return printf("%s %s --write-mode=overwrite --file-lines '[%s]'", g:rustfmt_command, g:rustfmt_options, json_encode(l:arg))
27+
endfunction
28+
29+
function! s:RustfmtCommand(filename)
30+
return g:rustfmt_command . " --write-mode=overwrite " . g:rustfmt_options . " " . shellescape(a:filename)
31+
endfunction
32+
33+
function! s:RunRustfmt(command, curw, tmpname)
34+
if exists("*systemlist")
35+
let out = systemlist(a:command)
36+
else
37+
let out = split(system(a:command), '\r\?\n')
38+
endif
39+
40+
if v:shell_error == 0 || v:shell_error == 3
41+
" remove undo point caused via BufWritePre
42+
try | silent undojoin | catch | endtry
43+
44+
" Replace current file with temp file, then reload buffer
45+
call rename(a:tmpname, expand('%'))
46+
silent edit!
47+
let &syntax = &syntax
48+
49+
" only clear location list if it was previously filled to prevent
50+
" clobbering other additions
51+
if s:got_fmt_error
52+
let s:got_fmt_error = 0
53+
call setloclist(0, [])
54+
lwindow
55+
endif
56+
elseif g:rustfmt_fail_silently == 0
57+
" otherwise get the errors and put them in the location list
58+
let errors = []
59+
60+
for line in out
61+
" src/lib.rs:13:5: 13:10 error: expected `,`, or `}`, found `value`
62+
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\):\s*\(\d\+:\d\+\s*\)\?\s*error: \(.*\)')
63+
if !empty(tokens)
64+
call add(errors, {"filename": @%,
65+
\"lnum": tokens[2],
66+
\"col": tokens[3],
67+
\"text": tokens[5]})
68+
endif
69+
endfor
70+
71+
if empty(errors)
72+
% | " Couldn't detect rustfmt error format, output errors
73+
endif
74+
75+
if !empty(errors)
76+
call setloclist(0, errors, 'r')
77+
echohl Error | echomsg "rustfmt returned error" | echohl None
78+
endif
79+
80+
let s:got_fmt_error = 1
81+
lwindow
82+
" We didn't use the temp file, so clean up
83+
call delete(a:tmpname)
84+
endif
85+
86+
call winrestview(a:curw)
87+
endfunction
88+
89+
function! rustfmt#FormatRange(line1, line2)
90+
let l:curw = winsaveview()
91+
let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt"
92+
call writefile(getline(1, '$'), l:tmpname)
93+
94+
let command = s:RustfmtCommandRange(l:tmpname, a:line1, a:line2)
95+
96+
call s:RunRustfmt(command, l:curw, l:tmpname)
97+
endfunction
98+
99+
function! rustfmt#Format()
100+
let l:curw = winsaveview()
101+
let l:tmpname = expand("%:p:h") . "/." . expand("%:p:t") . ".rustfmt"
102+
call writefile(getline(1, '$'), l:tmpname)
103+
104+
let command = s:RustfmtCommand(l:tmpname)
105+
106+
call s:RunRustfmt(command, l:curw, l:tmpname)
107+
endfunction

runtime/compiler/cargo.vim

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
" Vim compiler file
2+
" Compiler: Cargo Compiler
3+
" Maintainer: Damien Radtke <[email protected]>
4+
" Latest Revision: 2014 Sep 24
5+
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
6+
7+
if exists('current_compiler')
8+
finish
9+
endif
10+
runtime compiler/rustc.vim
11+
let current_compiler = "cargo"
12+
13+
let s:save_cpo = &cpo
14+
set cpo&vim
15+
16+
if exists(':CompilerSet') != 2
17+
command -nargs=* CompilerSet setlocal <args>
18+
endif
19+
20+
if exists('g:cargo_makeprg_params')
21+
execute 'CompilerSet makeprg=cargo\ '.escape(g:cargo_makeprg_params, ' \|"').'\ $*'
22+
else
23+
CompilerSet makeprg=cargo\ $*
24+
endif
25+
26+
" Ignore general cargo progress messages
27+
CompilerSet errorformat+=
28+
\%-G%\\s%#Downloading%.%#,
29+
\%-G%\\s%#Compiling%.%#,
30+
\%-G%\\s%#Finished%.%#,
31+
\%-G%\\s%#error:\ Could\ not\ compile\ %.%#,
32+
\%-G%\\s%#To\ learn\ more\\,%.%#
33+
34+
let &cpo = s:save_cpo
35+
unlet s:save_cpo

runtime/compiler/rustc.vim

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
" Vim compiler file
2+
" Compiler: Rust Compiler
3+
" Maintainer: Chris Morgan <[email protected]>
4+
" Latest Revision: 2013 Jul 12
5+
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
6+
7+
if exists("current_compiler")
8+
finish
9+
endif
10+
let current_compiler = "rustc"
11+
12+
let s:cpo_save = &cpo
13+
set cpo&vim
14+
15+
if exists(":CompilerSet") != 2
16+
command -nargs=* CompilerSet setlocal <args>
17+
endif
18+
19+
if exists("g:rustc_makeprg_no_percent") && g:rustc_makeprg_no_percent != 0
20+
CompilerSet makeprg=rustc
21+
else
22+
CompilerSet makeprg=rustc\ \%
23+
endif
24+
25+
" Old errorformat (before nightly 2016/08/10)
26+
CompilerSet errorformat=
27+
\%f:%l:%c:\ %t%*[^:]:\ %m,
28+
\%f:%l:%c:\ %*\\d:%*\\d\ %t%*[^:]:\ %m,
29+
\%-G%f:%l\ %s,
30+
\%-G%*[\ ]^,
31+
\%-G%*[\ ]^%*[~],
32+
\%-G%*[\ ]...
33+
34+
" New errorformat (after nightly 2016/08/10)
35+
CompilerSet errorformat+=
36+
\%-G,
37+
\%-Gerror:\ aborting\ %.%#,
38+
\%-Gerror:\ Could\ not\ compile\ %.%#,
39+
\%Eerror:\ %m,
40+
\%Eerror[E%n]:\ %m,
41+
\%Wwarning:\ %m,
42+
\%Inote:\ %m,
43+
\%C\ %#-->\ %f:%l:%c
44+
45+
let &cpo = s:cpo_save
46+
unlet s:cpo_save

runtime/doc/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ DOCS = \
3030
filetype.txt \
3131
fold.txt \
3232
ft_ada.txt \
33+
ft_rust.txt \
3334
ft_sql.txt \
3435
gui.txt \
3536
gui_w32.txt \
@@ -165,6 +166,7 @@ HTMLS = \
165166
filetype.html \
166167
fold.html \
167168
ft_ada.html \
169+
ft_rust.html \
168170
ft_sql.html \
169171
gui.html \
170172
gui_w32.html \

runtime/doc/eval.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.0. Last change: 2017 Mar 18
1+
*eval.txt* For Vim version 8.0. Last change: 2017 Mar 21
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2261,12 +2261,13 @@ readfile({fname} [, {binary} [, {max}]])
22612261
reltime([{start} [, {end}]]) List get time value
22622262
reltimefloat({time}) Float turn the time value into a Float
22632263
reltimestr({time}) String turn time value into a String
2264-
remote_expr({server}, {string} [, {idvar}])
2264+
remote_expr({server}, {string} [, {idvar} [, {timeout}]])
22652265
String send expression
22662266
remote_foreground({server}) Number bring Vim server to the foreground
22672267
remote_peek({serverid} [, {retvar}])
22682268
Number check for reply string
2269-
remote_read({serverid}) String read reply string
2269+
remote_read({serverid} [, {timeout}])
2270+
String read reply string
22702271
remote_send({server}, {string} [, {idvar}])
22712272
String send key sequence
22722273
remote_startserver({name}) none become server {name}

runtime/doc/filetype.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*filetype.txt* For Vim version 8.0. Last change: 2017 Jan 04
1+
*filetype.txt* For Vim version 8.0. Last change: 2017 Mar 21
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -663,6 +663,12 @@ Since the text for this plugin is rather long it has been put in a separate
663663
file: |pi_spec.txt|.
664664

665665

666+
RUST *ft-rust*
667+
668+
Since the text for this plugin is rather long it has been put in a separate
669+
file: |ft_rust.txt|.
670+
671+
666672
SQL *ft-sql*
667673

668674
Since the text for this plugin is rather long it has been put in a separate

runtime/doc/fold.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*fold.txt* For Vim version 8.0. Last change: 2016 Jan 02
1+
*fold.txt* For Vim version 8.0. Last change: 2017 Mar 18
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -79,7 +79,7 @@ This will call a function to compute the fold level: >
7979
:set foldexpr=MyFoldLevel(v:lnum)
8080
This will make a fold out of paragraphs separated by blank lines: >
8181
:set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1
82-
this does the same: >
82+
This does the same: >
8383
:set foldexpr=getline(v:lnum-1)=~'^\\s*$'&&getline(v:lnum)=~'\\S'?'>1':1
8484
8585
Note that backslashes must be used to escape characters that ":set" handles
@@ -203,7 +203,7 @@ and the level given by the marker:
203203
1. If a marker with the same fold level is encountered, the previous fold
204204
ends and another fold with the same level starts.
205205
2. If a marker with a higher fold level is found, a nested fold is started.
206-
3. if a marker with a lower fold level is found, all folds up to and including
206+
3. If a marker with a lower fold level is found, all folds up to and including
207207
this level end and a fold with the specified level starts.
208208

209209
The number indicates the fold level. A zero cannot be used (a marker with

0 commit comments

Comments
 (0)