# HG changeset patch # User Meredith Howard # Date 1571421927 14400 # Node ID ffc6f9c140cda9bb91cbe9fb708a2eb02d2bb215 # Parent 8e0452d9316c60ad0bdf1830ed418ac130986149 Move this Ag stuff into a function, remove flickers diff --git a/.vim/autoload/vimrc.vim b/.vim/autoload/vimrc.vim --- a/.vim/autoload/vimrc.vim +++ b/.vim/autoload/vimrc.vim @@ -31,6 +31,27 @@ func! vimrc#AutoSessionConfig() abort endif endfunc +func! vimrc#Ag(args) abort + let orig_t_ti = &t_ti + let orig_t_te = &t_te + let orig_shellpipe = &shellpipe + + set t_ti= t_te= + let &shellpipe = substitute(&shellpipe, '| tee', ' >', '') + + try + silent! execute "grep " . escape(a:args, '|') + copen + + let @/ = matchstr(a:args, "\\v(-)\@", 'n') + finally + let &t_ti = orig_t_ti + let &t_te = orig_t_te + let &shellpipe = orig_shellpipe + endtry +endfunc + func! vimrc#Gcd() abort let root = system('git rev-parse --show-toplevel 2>/dev/null')[:-2] if ! v:shell_error diff --git a/.vimrc b/.vimrc --- a/.vimrc +++ b/.vimrc @@ -126,7 +126,7 @@ command! Gcd call vimrc#Gcd() command! Hgcd call vimrc#Hgcd() command! SyntaxCompleteOn setl omnifunc=syntaxcomplete#Complete -command! -nargs=+ -complete=file -bar Ag sil! gr |cope|redr!|let @/=""|set hls +command! -nargs=+ -complete=file -bar Ag call vimrc#Ag() CAlias Rg Ag CAlias Q q @@ -232,10 +232,10 @@ if has('persistent_undo') endif if executable('rg') - set grepprg=rg\ --vimgrep\ --no-heading + set grepprg=rg\ --vimgrep set grepformat=%f:%l:%c:%m,%f:%l%m,%f\ \ %l%m elseif executable('ag') - set grepprg=ag\ --nogroup\ --nocolor\ --vimgrep + set grepprg=ag\ --vimgrep set grepformat^=%f:%l:%c:%m endif