dotfiles/nvim/.config/nvim/plugin/grepper.vim

20 lines
736 B
VimL
Raw Normal View History

if executable('rg')
set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case
set grepformat=%f:%l:%c:%m,%f:%l%m,%f\ \ %l%m
elseif executable('ag')
set grepprg=ag\ --nogroup\ --nocolor\ --vimgrep
set grepformat^=%f:%l:%c:%m
endif
" Taken from https://github.com/hauleth/dotfiles/blob/master/vim/.config/nvim/init.vim
command! -bang -nargs=* -complete=dir Grep call asyncdo#run(<bang>0,
\ { 'job': &grepprg, 'errorformat': &grepformat }, <f-args>)
command! -bang -nargs=* -complete=dir LGrep call asyncdo#lrun(<bang>0,
\ { 'job': &grepprg, 'errorformat': &grepformat }, <f-args>)
augroup GrepperQFOpen
autocmd!
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
augroup END