robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
2dd5e472df
master
1" Last Modified: 2023-09-11 2 3function ! cargo#quickfix#CmdPre () abort 4if & filetype ==# 'rust' && get ( b:, 'current_compiler' , '' ) ==# 'cargo' && 5 \& makeprg =~ '\V\^cargo\ \.\*' 6" Preserve the current directory, and 'lcd' to the nearest Cargo file. 7let b: rust_compiler_cargo_qf_has_lcd = haslocaldir () 8let b: rust_compiler_cargo_qf_prev_cd = getcwd () 9let b: rust_compiler_cargo_qf_prev_cd_saved = 1 10let l: nearest = fnamemodify ( cargo#nearestRootCargo ( 0 ), ':h' ) 11execute 'lchdir! ' . l: nearest 12else 13let b: rust_compiler_cargo_qf_prev_cd_saved = 0 14endif 15endfunction 16 17function ! cargo#quickfix#CmdPost () abort 18if exists ( "b:rust_compiler_cargo_qf_prev_cd_saved" ) && b: rust_compiler_cargo_qf_prev_cd_saved 19" Restore the current directory. 20if b: rust_compiler_cargo_qf_has_lcd 21execute 'lchdir! ' . b: rust_compiler_cargo_qf_prev_cd 22else 23execute 'chdir! ' . b: rust_compiler_cargo_qf_prev_cd 24endif 25let b: rust_compiler_cargo_qf_prev_cd_saved = 0 26endif 27endfunction 28 29" vim: set et sw=4 sts=4 ts=8: