mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -05:00
Make :Glog and :Ggrep global
This commit is contained in:
@@ -3659,11 +3659,11 @@ if !exists('g:fugitive_summary_format')
|
||||
let g:fugitive_summary_format = '%s'
|
||||
endif
|
||||
|
||||
function! s:GrepComplete(A, L, P) abort
|
||||
function! fugitive#GrepComplete(A, L, P) abort
|
||||
return s:CompleteSub('grep', a:A, a:L, a:P)
|
||||
endfunction
|
||||
|
||||
function! s:LogComplete(A, L, P) abort
|
||||
function! fugitive#LogComplete(A, L, P) abort
|
||||
return s:CompleteSub('log', a:A, a:L, a:P)
|
||||
endfunction
|
||||
|
||||
@@ -3806,7 +3806,7 @@ function! s:LogParse(state, dir, line) abort
|
||||
return []
|
||||
endfunction
|
||||
|
||||
function! s:Log(type, bang, line1, count, args, legacy) abort
|
||||
function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort
|
||||
let dir = s:Dir()
|
||||
exe s:DirCheck(dir)
|
||||
let listnr = a:type =~# '^l' ? 0 : -1
|
||||
@@ -3877,19 +3877,12 @@ function! s:Log(type, bang, line1, count, args, legacy) abort
|
||||
\ args + paths + extra)
|
||||
let state.target = path
|
||||
let title = (listnr < 0 ? ':Gclog ' : ':Gllog ') . s:fnameescape(args + paths)
|
||||
if empty(paths + extra) && a:legacy && len(s:Relative('/'))
|
||||
if empty(paths + extra) && empty(a:type) && len(s:Relative('/'))
|
||||
let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after
|
||||
endif
|
||||
return s:QuickfixStream(listnr, title, s:UserCommandList(dir) + cmd, !a:bang, s:function('s:LogParse'), state, dir) . after
|
||||
endfunction
|
||||
|
||||
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, <bang>0, '<mods>', <q-args>)")
|
||||
call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:GrepSubcommand(0, 0, 0, <bang>0, '<mods>', <q-args>)")
|
||||
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Glog :exe s:Log('c',<bang>0,<line1>,<count>,<q-args>, 1)")
|
||||
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gclog :exe s:Log('c',<bang>0,<line1>,<count>,<q-args>, 0)")
|
||||
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gllog :exe s:Log('l',<bang>0,<line1>,<count>,<q-args>, 0)")
|
||||
|
||||
" Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread
|
||||
|
||||
function! s:UsableWin(nr) abort
|
||||
|
||||
@@ -359,12 +359,21 @@ augroup END
|
||||
|
||||
let s:addr_other = has('patch-8.1.560') ? '-addr=other' : ''
|
||||
let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
|
||||
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete G exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete Git exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
||||
|
||||
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(<q-args>, 0)"
|
||||
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(<q-args>, 1)"
|
||||
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "grep " . <q-args>)'
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "grep " . <q-args>)'
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#Command(0, <count> > 0 ? <count> : 0, +"<range>", <bang>0, "<mods>", "grep " . <q-args>)'
|
||||
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,<q-args>, "")'
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#LogComplete Gllog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
|
||||
|
||||
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Ge exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
|
||||
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gedit exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
|
||||
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
||||
|
||||
Reference in New Issue
Block a user