-
Notifications
You must be signed in to change notification settings - Fork 303
Improved syntastic linting #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,29 @@ if exists("g:loaded_syntastic_rust_rustc_checker") | |
endif | ||
let g:loaded_syntastic_rust_rustc_checker = 1 | ||
|
||
if !exists('g:rustc_syntax_only') | ||
let g:rustc_syntax_only = 1 "Keep the fast behaviour by default | ||
endif | ||
|
||
let s:save_cpo = &cpo | ||
set cpo&vim | ||
|
||
function! SyntaxCheckers_rust_rustc_GetLocList() dict | ||
let makeprg = self.makeprgBuild({ 'args': '-Zparse-only' }) | ||
let compiler_params = g:rustc_syntax_only ? '-Zparse-only' : '-Zno-trans' | ||
let cwd = '.' " Don't change cwd as default | ||
let cargo_toml_path = findfile('Cargo.toml', '.;') | ||
if empty(cargo_toml_path) " Plain rs file, not a crate | ||
let makeprg = self.makeprgBuild({ | ||
\ 'exe': 'rustc', | ||
\ 'args': compiler_params}) | ||
else " We are inside a crate | ||
let makeprg = self.makeprgBuild({ | ||
\ 'exe': 'cargo', | ||
\ 'args': 'rustc ' . compiler_params, | ||
\ 'fname': '' }) | ||
" Change cwd to the root of the crate | ||
let cwd = fnamemodify( cargo_toml_path, ':p:h') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line currently doesn't work inside a workspace, for it needs to find workspace's Cargo.toml (which is ../ relative to what it currently finds), so reported filenames in the errors are like: I don't know of a way to detect if we're inside a workspace now... EDIT: I opted to patch |
||
endif | ||
|
||
let errorformat = | ||
\ '%E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,' . | ||
|
@@ -24,12 +42,13 @@ function! SyntaxCheckers_rust_rustc_GetLocList() dict | |
|
||
return SyntasticMake({ | ||
\ 'makeprg': makeprg, | ||
\ 'errorformat': errorformat }) | ||
\ 'errorformat': errorformat, | ||
\ 'cwd': cwd }) | ||
endfunction | ||
|
||
call g:SyntasticRegistry.CreateAndRegisterChecker({ | ||
\ 'filetype': 'rust', | ||
\ 'name': 'rustc'}) | ||
\ 'name': 'rustc' }) | ||
|
||
let &cpo = s:save_cpo | ||
unlet s:save_cpo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this search in parent directories or only in current dir and subdirs? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the current and parent directories until it finds the file.
See
:help findfile()