:Glgrep and :Gllog
This commit is contained in:
parent
49e6c2b676
commit
b978d9f0be
@ -69,12 +69,20 @@ that are part of Git repositories).
|
||||
*fugitive-:Ggrep*
|
||||
:Ggrep [args] |:grep| with git-grep as 'grepprg'.
|
||||
|
||||
*fugitive-:Glgrep*
|
||||
:Glgrep [args] |:lgrep| with git-grep as 'grepprg'.
|
||||
|
||||
*fugitive-:Glog*
|
||||
:Glog [args] Load all previous revisions of the current file into
|
||||
the quickfix list. Additional git-log arguments can
|
||||
be given (for example, --reverse). If "--" appears as
|
||||
an argument, no file specific filtering is done, and
|
||||
commits are loaded into the quickfix list.
|
||||
previous commits rather than previous file revisions
|
||||
are loaded.
|
||||
|
||||
*fugitive-:Gllog*
|
||||
:Gllog [args] Like |:Glog|, but use the location list instead of the
|
||||
quickfix list.
|
||||
|
||||
*fugitive-:Gedit* *fugitive-:Ge*
|
||||
:Gedit [revision] |:edit| a |fugitive-revision|.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user