From 79b1f16a7adf38ed5e202e5317cc1eabc9399528 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 11 Aug 2019 21:27:59 -0400 Subject: [PATCH] Delegate :Git grep to :Ggrep --- autoload/fugitive.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index b307b77..f40f509 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -3704,16 +3704,20 @@ function! s:GrepParseLine(prefix, name_only, dir, line) abort return entry endfunction -function! s:Grep(listnr, bang, arg) abort +function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort let dir = s:Dir() exe s:DirCheck(dir) - let listnr = a:listnr + let listnr = a:line1 == 0 ? a:line1 : a:line2 let cmd = s:UserCommandList(dir) + ['--no-pager', 'grep', '-n', '--no-color', '--full-name'] if fugitive#GitVersion(2, 19) call add(cmd, '--column') endif let tree = s:Tree(dir) - let [args, after] = s:SplitExpandChain(a:arg, tree) + if type(a:args) == type([]) + let [args, after] = [a:args, ''] + else + let [args, after] = s:SplitExpandChain(a:args, tree) + endif let prefix = s:PlatformSlash(s:HasOpt(args, '--cached') || empty(tree) ? 'fugitive://' . dir . '//0/' : tree . '/') let name_only = s:HasOpt(args, '-l', '--files-with-matches', '--name-only', '-L', '--files-without-match') let title = [listnr < 0 ? ':Ggrep' : ':Glgrep'] + args @@ -3859,9 +3863,9 @@ function! s:Log(type, bang, line1, count, args) abort return s:QuickfixStream(listnr, title, cmd, !a:bang, s:function('s:LogParse'), state, path, dir) . after endfunction -call s:command("-bang -nargs=? -range=-1 -addr=windows -complete=customlist,s:GrepComplete Ggrep :execute s:Grep(,0,)") -call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Gcgrep :execute s:Grep(-1,0,)") -call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:Grep(0,0,)") +call s:command("-bang -nargs=? -range=-1 -addr=windows -complete=customlist,s:GrepComplete Ggrep", "grep") +call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Gcgrep :execute s:GrepSubcommand(-1, -1, 0, 0, '', )") +call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:GrepSubcommand(0, 0, 0, 0, '', )") call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Glog :exe s:Log('c',0,,,)") call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gclog :exe s:Log('c',0,,,)") call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gllog :exe s:Log('l',0,,,)")