File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,20 @@ let s:save_cpo = &cpo
14
14
set cpo &vim
15
15
16
16
function ! SyntaxCheckers_rust_rustc_GetLocList () dict
17
- let makeprg = self .makeprgBuild ({ ' args' : ' -Zparse-only' })
17
+ let cwd = ' .' " Don't change cwd as default
18
+ let cargo_toml_path = findfile (' Cargo.toml' , ' .;' )
19
+ if empty (cargo_toml_path) " Plain rs file, not a crate
20
+ let makeprg = self .makeprgBuild ({
21
+ \ ' exe' : ' rustc' ,
22
+ \ ' args' : ' -Zno-trans' })
23
+ else " We are inside a crate
24
+ let makeprg = self .makeprgBuild ({
25
+ \ ' exe' : ' cargo' ,
26
+ \ ' args' : ' rustc -Zno-trans' ,
27
+ \ ' fname' : ' ' })
28
+ " Change cwd to the root of the crate
29
+ let cwd = fnamemodify ( cargo_toml_path, ' :p:h' )
30
+ endif
18
31
19
32
let errorformat =
20
33
\ ' %E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,' .
@@ -24,12 +37,13 @@ function! SyntaxCheckers_rust_rustc_GetLocList() dict
24
37
25
38
return SyntasticMake ({
26
39
\ ' makeprg' : makeprg ,
27
- \ ' errorformat' : errorformat })
40
+ \ ' errorformat' : errorformat ,
41
+ \ ' cwd' : cwd })
28
42
endfunction
29
43
30
44
call g: SyntasticRegistry .CreateAndRegisterChecker ({
31
45
\ ' filetype' : ' rust' ,
32
- \ ' name' : ' rustc' })
46
+ \ ' name' : ' rustc' })
33
47
34
48
let &cpo = s: save_cpo
35
49
unlet s: save_cpo
You can’t perform that action at this time.
0 commit comments