mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 06:13:51 -05:00
Make remaining buffer commands global
This commit is contained in:
@@ -592,39 +592,6 @@ function! s:add_methods(namespace, method_names) abort
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Command(command, line1, line2, range, bang, mods, arg, args) abort
|
|
||||||
try
|
|
||||||
if a:command =~# '^\l[[:alnum:]-]\+$'
|
|
||||||
return fugitive#Command(a:line1, a:line2, a:range, a:bang, s:Mods(a:mods), a:command . ' ' . a:arg)
|
|
||||||
endif
|
|
||||||
return s:{a:command}Command(a:line1, a:line2, a:range, a:line2, a:bang, s:Mods(a:mods), '', a:arg, a:args)
|
|
||||||
catch /^fugitive:/
|
|
||||||
return 'echoerr ' . string(v:exception)
|
|
||||||
endtry
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:commands = []
|
|
||||||
function! s:command(definition, ...) abort
|
|
||||||
let def = a:definition
|
|
||||||
if !has('patch-7.4.542')
|
|
||||||
let def = substitute(def, '-addr=\S\+ ', '', '')
|
|
||||||
endif
|
|
||||||
if !has('patch-8.1.560')
|
|
||||||
let def = substitute(def, '-addr=other ', '', '')
|
|
||||||
endif
|
|
||||||
if a:0
|
|
||||||
call add(s:commands, def . ' execute s:Command(' . string(a:1) . ", <line1>, <count>, +'<range>', <bang>0, '<mods>', <q-args>, [<f-args>])")
|
|
||||||
else
|
|
||||||
call add(s:commands, def)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:define_commands() abort
|
|
||||||
for command in s:commands
|
|
||||||
exe 'command! -buffer '.command
|
|
||||||
endfor
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:repo_prototype = {}
|
let s:repo_prototype = {}
|
||||||
let s:repos = {}
|
let s:repos = {}
|
||||||
|
|
||||||
@@ -2216,8 +2183,6 @@ endfunction
|
|||||||
|
|
||||||
" Section: :Gstatus
|
" Section: :Gstatus
|
||||||
|
|
||||||
call s:command("-bar -bang -range=-1 -addr=other Gstatus", "Status")
|
|
||||||
|
|
||||||
function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args, ...) abort
|
function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args, ...) abort
|
||||||
let dir = a:0 ? a:1 : s:Dir()
|
let dir = a:0 ? a:1 : s:Dir()
|
||||||
exe s:DirCheck(dir)
|
exe s:DirCheck(dir)
|
||||||
@@ -3439,9 +3404,6 @@ function! s:FinishCommit() abort
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call s:command("-nargs=? -range=-1 -complete=customlist,fugitive#CommitComplete Gcommit", "commit")
|
|
||||||
call s:command("-nargs=? -range=-1 -complete=customlist,fugitive#RevertComplete Grevert", "revert")
|
|
||||||
|
|
||||||
" Section: :Gmerge, :Grebase, :Gpull
|
" Section: :Gmerge, :Grebase, :Gpull
|
||||||
|
|
||||||
function! fugitive#MergeComplete(A, L, P) abort
|
function! fugitive#MergeComplete(A, L, P) abort
|
||||||
@@ -3719,10 +3681,6 @@ augroup fugitive_merge
|
|||||||
\ endif
|
\ endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
call s:command("-nargs=? -bang -complete=customlist,fugitive#MergeComplete Gmerge", "merge")
|
|
||||||
call s:command("-nargs=? -bang -complete=customlist,fugitive#RebaseComplete Grebase", "rebase")
|
|
||||||
call s:command("-nargs=? -bang -complete=customlist,fugitive#PullComplete Gpull", "pull")
|
|
||||||
|
|
||||||
" Section: :Ggrep, :Glog
|
" Section: :Ggrep, :Glog
|
||||||
|
|
||||||
if !exists('g:fugitive_summary_format')
|
if !exists('g:fugitive_summary_format')
|
||||||
@@ -4383,9 +4341,6 @@ function! s:FetchSubcommand(line1, line2, range, bang, mods, args) abort
|
|||||||
return s:Dispatch(a:bang ? '!' : '', 'fetch', a:args)
|
return s:Dispatch(a:bang ? '!' : '', 'fetch', a:args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call s:command("-nargs=? -bang -complete=customlist,fugitive#PushComplete Gpush", "push")
|
|
||||||
call s:command("-nargs=? -bang -complete=customlist,fugitive#FetchComplete Gfetch", "fetch")
|
|
||||||
|
|
||||||
" Section: :Gdiff
|
" Section: :Gdiff
|
||||||
|
|
||||||
augroup fugitive_diff
|
augroup fugitive_diff
|
||||||
@@ -5216,8 +5171,6 @@ augroup fugitive_blame
|
|||||||
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
|
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
call s:command('-buffer -bang -range=-1 -nargs=? -complete=customlist,fugitive#BlameComplete Gblame', 'blame')
|
|
||||||
|
|
||||||
" Section: :Gbrowse
|
" Section: :Gbrowse
|
||||||
|
|
||||||
let s:redirects = {}
|
let s:redirects = {}
|
||||||
@@ -5977,7 +5930,6 @@ function! fugitive#Init() abort
|
|||||||
echohl NONE
|
echohl NONE
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call s:define_commands()
|
|
||||||
exe s:DoAutocmd('User Fugitive')
|
exe s:DoAutocmd('User Fugitive')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -361,9 +361,21 @@ augroup END
|
|||||||
let s:addr_other = has('patch-8.1.560') ? '-addr=other' : ''
|
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_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
|
||||||
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
|
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 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! -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! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
||||||
|
|
||||||
|
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#CommitComplete Gcommit exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "commit " . <q-args>)'
|
||||||
|
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#RevertComplete Grevert exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "revert " . <q-args>)'
|
||||||
|
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#MergeComplete Gmerge exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "merge " . <q-args>)'
|
||||||
|
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#RebaseComplete Grebase exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "rebase " . <q-args>)'
|
||||||
|
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#PullComplete Gpull exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "pull " . <q-args>)'
|
||||||
|
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#PushComplete Gpush exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "push " . <q-args>)'
|
||||||
|
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#FetchComplete Gfetch exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "fetch " . <q-args>)'
|
||||||
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#BlameComplete Gblame exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "blame " . <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 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! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(<q-args>, 1)"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user