Skip to content

Commit b5d9e94

Browse files
BurntSushialexcrichton
authored andcommitted
Add a Syntastic plugin for Rust.
1 parent ebde8cf commit b5d9e94

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/etc/vim/plugin/rust.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
" Vim syntastic plugin helper
2+
" Language: Rust
3+
" Maintainer: Andrew Gallant <[email protected]>
4+
5+
if exists("g:loaded_syntastic_rust_filetype")
6+
finish
7+
endif
8+
let g:loaded_syntastic_rust_filetype = 1
9+
let s:save_cpo = &cpo
10+
set cpo&vim
11+
12+
" This is to let Syntastic know about the Rust filetype.
13+
" It enables tab completion for the 'SyntasticInfo' command.
14+
" (This does not actually register the syntax checker.)
15+
if exists('g:syntastic_extra_filetypes')
16+
call add(g:syntastic_extra_filetypes, 'rust')
17+
else
18+
let g:syntastic_extra_filetypes = ['rust']
19+
endif
20+
21+
let &cpo = s:save_cpo
22+
unlet s:save_cpo
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
" Vim syntastic plugin
2+
" Language: Rust
3+
" Maintainer: Andrew Gallant <[email protected]>
4+
"
5+
" See for details on how to add an external Syntastic checker:
6+
" https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide#external
7+
8+
if exists("g:loaded_syntastic_rust_rustc_checker")
9+
finish
10+
endif
11+
let g:loaded_syntastic_rust_rustc_checker = 1
12+
13+
let s:save_cpo = &cpo
14+
set cpo&vim
15+
16+
function! SyntaxCheckers_rust_rustc_GetLocList() dict
17+
let makeprg = self.makeprgBuild({ 'args': '--parse-only' })
18+
19+
let errorformat =
20+
\ '%E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,' .
21+
\ '%W%f:%l:%c: %\d%#:%\d%# %.%\{-}warning:%.%\{-} %m,' .
22+
\ '%C%f:%l %m,' .
23+
\ '%-Z%.%#'
24+
25+
return SyntasticMake({
26+
\ 'makeprg': makeprg,
27+
\ 'errorformat': errorformat })
28+
endfunction
29+
30+
call g:SyntasticRegistry.CreateAndRegisterChecker({
31+
\ 'filetype': 'rust',
32+
\ 'name': 'rustc'})
33+
34+
let &cpo = s:save_cpo
35+
unlet s:save_cpo

0 commit comments

Comments
 (0)