From d6add4dee3b2a1cb796d975b7991aa887aa21a93 Mon Sep 17 00:00:00 2001 From: Andreas Innerlohninger Date: Wed, 22 Feb 2017 20:41:37 +0100 Subject: [PATCH 1/2] Add cargo as a checker for syntastic --- syntax_checkers/rust/cargo.vim | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 syntax_checkers/rust/cargo.vim diff --git a/syntax_checkers/rust/cargo.vim b/syntax_checkers/rust/cargo.vim new file mode 100644 index 00000000..60ccf908 --- /dev/null +++ b/syntax_checkers/rust/cargo.vim @@ -0,0 +1,55 @@ +" Vim syntastic plugin +" Language: Rust +" Maintainer: Innerand +" +" Adapted version of the rustc plugin by Andrew Gallant +" +" See for details on how to add an external Syntastic checker: +" https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide#external +" +" TODO: Runs a full build for syntax checking. Add arg for syntax check +" only once it is supported by cargo/rustc. + +if exists("g:loaded_syntastic_rust_cargo_checker") + finish +endif +let g:loaded_syntastic_rust_cargo_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_rust_cargo_GetLocList() dict + let makeprg = self.makeprgBuild({ + \ 'args': 'build', + \ 'fname': '' }) + + " Old errorformat (before nightly 2016/08/10) + let errorformat = + \ '%E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,' . + \ '%W%f:%l:%c: %\d%#:%\d%# %.%\{-}warning:%.%\{-} %m,' . + \ '%C%f:%l %m' + + " New errorformat (after nightly 2016/08/10) + let errorformat .= + \ ',' . + \ '%-G,' . + \ '%-Gerror: aborting %.%#,' . + \ '%-Gerror: Could not compile %.%#,' . + \ '%Eerror: %m,' . + \ '%Eerror[E%n]: %m,' . + \ '%-Gwarning: the option `Z` is unstable %.%#,' . + \ '%Wwarning: %m,' . + \ '%Inote: %m,' . + \ '%C %#--> %f:%l:%c' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'rust', + \ 'name': 'cargo'}) + +let &cpo = s:save_cpo +unlet s:save_cpo From 143cdbcc70a5c065dfe77e65ff5bb4b9e4b83313 Mon Sep 17 00:00:00 2001 From: Andreas Innerlohninger Date: Thu, 16 Mar 2017 18:43:19 +0100 Subject: [PATCH 2/2] Use cargo's new check option --- syntax_checkers/rust/cargo.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/syntax_checkers/rust/cargo.vim b/syntax_checkers/rust/cargo.vim index 60ccf908..129357ee 100644 --- a/syntax_checkers/rust/cargo.vim +++ b/syntax_checkers/rust/cargo.vim @@ -7,8 +7,6 @@ " See for details on how to add an external Syntastic checker: " https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide#external " -" TODO: Runs a full build for syntax checking. Add arg for syntax check -" only once it is supported by cargo/rustc. if exists("g:loaded_syntastic_rust_cargo_checker") finish @@ -20,7 +18,7 @@ set cpo&vim function! SyntaxCheckers_rust_cargo_GetLocList() dict let makeprg = self.makeprgBuild({ - \ 'args': 'build', + \ 'args': 'check', \ 'fname': '' }) " Old errorformat (before nightly 2016/08/10)