Skip to content

Commit 9c9c38b

Browse files
committed
Add a cargo syntax checker
1 parent eed97e7 commit 9c9c38b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

syntax_checkers/rust/cargo.vim

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
" Vim syntastic plugin
2+
" Language: Rust
3+
" Maintainer: Julien Levesy <jlevesy@gmail.com>
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_cargo_checker")
9+
finish
10+
endif
11+
let g:loaded_syntastic_rust_cargo_checker = 1
12+
13+
let g:syntastic_rust_cargo_fname = ""
14+
15+
let s:save_cpo = &cpo
16+
set cpo&vim
17+
18+
function! SyntaxCheckers_rust_cargo_IsAvailable() dict
19+
return executable(self.getExec())
20+
endfunction
21+
22+
function! SyntaxCheckers_rust_cargo_GetLocList() dict
23+
let makeprg = self.makeprgBuild({ "args": "check" })
24+
25+
" Ignored patterns, and blank lines
26+
let errorformat =
27+
\ '%-G,' .
28+
\ '%-Gerror: aborting %.%#,' .
29+
\ '%-Gerror: Could not compile %.%#,' .
30+
\ '%-Gwarning: the option `Z` is unstable %.%#,'
31+
32+
" Meaningful lines (errors, notes, warnings, contextual information)
33+
let errorformat .=
34+
\ '%Eerror: %m,' .
35+
\ '%Eerror[E%n]: %m,' .
36+
\ '%Wwarning: %m,' .
37+
\ '%Inote: %m,' .
38+
\ '%C %#--> %f:%l:%c'
39+
40+
return SyntasticMake({
41+
\ 'makeprg': makeprg,
42+
\ 'errorformat': errorformat })
43+
endfunction
44+
45+
call g:SyntasticRegistry.CreateAndRegisterChecker({
46+
\ 'filetype': 'rust',
47+
\ 'name': 'cargo'})
48+
49+
let &cpo = s:save_cpo
50+
unlet s:save_cpo

0 commit comments

Comments
 (0)