File tree 2 files changed +32
-0
lines changed
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ function ! cargo#quickfix#CmdPre () abort
2
+ if &filetype == # ' rust' && get (b: , ' current_compiler' , ' ' ) == # ' cargo'
3
+ " Preserve the current directory, and 'lcd' to the nearest Cargo file.
4
+ let b: rust_compiler_cargo_qf_has_lcd = haslocaldir ()
5
+ let b: rust_compiler_cargo_qf_prev_cd = getcwd ()
6
+ let b: rust_compiler_cargo_qf_prev_cd_saved = 1
7
+ let l: nearest = fnamemodify (cargo#nearestRootCargo (0 ), ' :h' )
8
+ execute ' lchdir! ' .l: nearest
9
+ else
10
+ let b: rust_compiler_cargo_qf_prev_cd_saved = 0
11
+ endif
12
+ endfunction
13
+
14
+ function ! cargo#quickfix#CmdPost () abort
15
+ if b: rust_compiler_cargo_qf_prev_cd_saved
16
+ " Restore the current directory.
17
+ if b: rust_compiler_cargo_qf_has_lcd
18
+ execute ' lchdir! ' .b: rust_compiler_cargo_qf_prev_cd
19
+ else
20
+ execute ' chdir! ' .b: rust_compiler_cargo_qf_prev_cd
21
+ endif
22
+ let b: rust_compiler_cargo_qf_prev_cd_saved = 0
23
+ endif
24
+ endfunction
25
+
26
+ " vim: set et sw = 4 sts = 4 ts = 8 :
Original file line number Diff line number Diff line change 23
23
CompilerSet makeprg = cargo\ $ *
24
24
endif
25
25
26
+ augroup RustCargoQuickFixHooks
27
+ autocmd !
28
+ autocmd QuickFixCmdPre make call cargo#quickfix#CmdPre ()
29
+ autocmd QuickFixCmdPost make call cargo#quickfix#CmdPost ()
30
+ augroup END
31
+
26
32
" Ignore general cargo progress messages
27
33
CompilerSet errorformat +=
28
34
\% - G% \\ s % #Downloading% .% #,
You can’t perform that action at this time.
0 commit comments