neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

quickfix.vim (1119B)


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