Add cargo as a checker for syntastic#147
Conversation
|
I just want to say that I have been using this for some months now without any issue. I hope it gets accepted |
|
Does this work correctly inside a workspace? (note: that #76 does not, for it finds the subproject Cargo.toml only, instead of workspace's Cargo.toml which is |
|
Looks like the file that this PR adds, already exists in the repo: https://github.com/rust-lang/rust.vim/blob/master/syntax_checkers/rust/cargo.vim --- thisPR/cargo.vim 2018-01-05 04:16:42.279586031 +0100
+++ repo/cargo.vim 2018-01-02 22:00:32.568566104 +0100
@@ -1,47 +1,47 @@
" Vim syntastic plugin
" Language: Rust
-" Maintainer: Innerand <innerand@nxa.at>
-"
-" Adapted version of the rustc plugin by Andrew Gallant
+" Maintainer: Julien Levesy <jlevesy@gmail.com>
"
" See for details on how to add an external Syntastic checker:
" https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide#external
-"
if exists("g:loaded_syntastic_rust_cargo_checker")
finish
endif
+
let g:loaded_syntastic_rust_cargo_checker = 1
+" Force syntastic to call cargo without a specific file name
+let g:syntastic_rust_cargo_fname = ""
+
let s:save_cpo = &cpo
set cpo&vim
+function! SyntaxCheckers_rust_cargo_IsAvailable() dict
+ return executable(self.getExec()) &&
+ \ syntastic#util#versionIsAtLeast(self.getVersion(), [0, 16, 0])
+endfunction
+
function! SyntaxCheckers_rust_cargo_GetLocList() dict
- let makeprg = self.makeprgBuild({
- \ 'args': 'check',
- \ 'fname': '' })
+ let makeprg = self.makeprgBuild({ "args": "check" })
- " Old errorformat (before nightly 2016/08/10)
+ " Ignored patterns, and blank lines
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 %.%#,' .
+ \ '%-Gerror: Could not compile %.%#,'
+
+ " Meaningful lines (errors, notes, warnings, contextual information)
+ let errorformat .=
\ '%Eerror: %m,' .
\ '%Eerror[E%n]: %m,' .
- \ '%-Gwarning: the option `Z` is unstable %.%#,' .
\ '%Wwarning: %m,' .
\ '%Inote: %m,' .
\ '%C %#--> %f:%l:%c'
return SyntasticMake({
\ 'makeprg': makeprg,
+ \ 'cwd': expand('%:p:h'),
\ 'errorformat': errorformat })
endfunction
|
|
This PR is from 03/17, that file was added by a PR from 12/16 merged in 08/17. |
|
well, from what I tested, neither handle the case when cwd is No matter though, I patched cargo, for my own use, to always pass absolute filenames to rustc, thus rustc-reported errors are always full paths, thus not needing any cwd changes for vim to show errors even in case of workspaces. |
Add
let g:syntastic_rust_checkers = ['cargo']to vimrc and syntastic usescargo checkfor syntax checking.