Skip to content

Commit a54bc38

Browse files
authored
Merge pull request #132 from jlevesy/master
Add a cargo checker for syntastic
2 parents 5a61336 + 29c61e1 commit a54bc38

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

syntax_checkers/rust/cargo.vim

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

0 commit comments

Comments
 (0)