mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-16 23:33:43 -05:00
:Glgrep and :Gllog
This commit is contained in:
@@ -914,10 +914,12 @@ if !exists('g:fugitive_summary_format')
|
||||
let g:fugitive_summary_format = '%s'
|
||||
endif
|
||||
|
||||
call s:command("-bang -nargs=? -complete=customlist,s:EditComplete Ggrep :execute s:Grep(<bang>0,<q-args>)")
|
||||
call s:command("-bang -nargs=? -complete=customlist,s:EditComplete Ggrep :execute s:Grep('grep',<bang>0,<q-args>)")
|
||||
call s:command("-bang -nargs=? -complete=customlist,s:EditComplete Glgrep :execute s:Grep('lgrep',<bang>0,<q-args>)")
|
||||
call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Glog :execute s:Log('grep<bang>',<f-args>)")
|
||||
call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gllog :execute s:Log('lgrep<bang>',<f-args>)")
|
||||
|
||||
function! s:Grep(bang,arg) abort
|
||||
function! s:Grep(cmd,bang,arg) abort
|
||||
let grepprg = &grepprg
|
||||
let grepformat = &grepformat
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
@@ -926,8 +928,8 @@ function! s:Grep(bang,arg) abort
|
||||
execute cd.'`=s:repo().tree()`'
|
||||
let &grepprg = s:repo().git_command('--no-pager', 'grep', '-n')
|
||||
let &grepformat = '%f:%l:%m'
|
||||
exe 'grep! '.escape(matchstr(a:arg,'\v\C.{-}%($|[''" ]\@=\|)@='),'|')
|
||||
let list = getqflist()
|
||||
exe a:cmd.'! '.escape(matchstr(a:arg,'\v\C.{-}%($|[''" ]\@=\|)@='),'|')
|
||||
let list = a:cmd =~# '^l' ? getloclist(0) : getqflist()
|
||||
for entry in list
|
||||
if bufname(entry.bufnr) =~ ':'
|
||||
let entry.filename = s:repo().translate(bufname(entry.bufnr))
|
||||
@@ -937,9 +939,13 @@ function! s:Grep(bang,arg) abort
|
||||
unlet! entry.bufnr
|
||||
endif
|
||||
endfor
|
||||
call setqflist(list,'r')
|
||||
if a:cmd =~# '^l'
|
||||
call setloclist(0, list, 'r')
|
||||
else
|
||||
setqflist(list, 'r')
|
||||
endif
|
||||
if !a:bang && !empty(list)
|
||||
return 'cfirst'.matchstr(a:arg,'\v\C[''" ]\zs\|.*')
|
||||
return (a:cmd =~# '^l' ? 'l' : 'c').'first'.matchstr(a:arg,'\v\C[''" ]\zs\|.*')
|
||||
else
|
||||
return matchstr(a:arg,'\v\C[''" ]\|\zs.*')
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user