File tree 1 file changed +17
-6
lines changed
1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -14,9 +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 ({
18
- \ ' args' : ' rustc -Zno-trans' ,
19
- \ ' fname' : ' ' })
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
20
31
21
32
let errorformat =
22
33
\ ' %E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,' .
@@ -26,13 +37,13 @@ function! SyntaxCheckers_rust_rustc_GetLocList() dict
26
37
27
38
return SyntasticMake ({
28
39
\ ' makeprg' : makeprg ,
29
- \ ' errorformat' : errorformat })
40
+ \ ' errorformat' : errorformat ,
41
+ \ ' cwd' : cwd })
30
42
endfunction
31
43
32
44
call g: SyntasticRegistry .CreateAndRegisterChecker ({
33
- \ ' exec' : ' cargo' ,
34
45
\ ' filetype' : ' rust' ,
35
- \ ' name' : ' rustc' })
46
+ \ ' name' : ' rustc' })
36
47
37
48
let &cpo = s: save_cpo
38
49
unlet s: save_cpo
You can’t perform that action at this time.
0 commit comments