motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit b978d9f0bebc2e50a68beafd80675c50253d0eca (tree)
parent 49e6c2b676fbb6aadaf3080828ea71633d05cd3b
Author: Tim Pope <code@tpope.net>
Date:   Thu,  5 Apr 2012 12:25:24 -0400

:Glgrep and :Gllog

Diffstat:
Mdoc/fugitive.txt | 10+++++++++-
Mplugin/fugitive.vim | 18++++++++++++------
2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/doc/fugitive.txt b/doc/fugitive.txt @@ -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|. diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim @@ -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