diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index c017d24..7dfb917 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -592,39 +592,6 @@ function! s:add_methods(namespace, method_names) abort endfor 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) . ", , , +'', 0, '', , [])") - 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:repos = {} @@ -2216,8 +2183,6 @@ endfunction " 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 let dir = a:0 ? a:1 : s:Dir() exe s:DirCheck(dir) @@ -3439,9 +3404,6 @@ function! s:FinishCommit() abort return '' 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 function! fugitive#MergeComplete(A, L, P) abort @@ -3719,10 +3681,6 @@ augroup fugitive_merge \ endif 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 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) 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 augroup fugitive_diff @@ -5216,8 +5171,6 @@ augroup fugitive_blame autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('')), 'fugitive_leave') augroup END -call s:command('-buffer -bang -range=-1 -nargs=? -complete=customlist,fugitive#BlameComplete Gblame', 'blame') - " Section: :Gbrowse let s:redirects = {} @@ -5977,7 +5930,6 @@ function! fugitive#Init() abort echohl NONE endif endif - call s:define_commands() exe s:DoAutocmd('User Fugitive') endfunction diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index efd9778..e778852 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -361,9 +361,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(, , +"", 0, "", )' exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete Git exe fugitive#Command(, , +"", 0, "", )' +exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(, , +"", 0, "", )' + +exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#CommitComplete Gcommit exe fugitive#Command(, , +"", 0, "", "commit " . )' +exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#RevertComplete Grevert exe fugitive#Command(, , +"", 0, "", "revert " . )' +exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#MergeComplete Gmerge exe fugitive#Command(, , +"", 0, "", "merge " . )' +exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#RebaseComplete Grebase exe fugitive#Command(, , +"", 0, "", "rebase " . )' +exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#PullComplete Gpull exe fugitive#Command(, , +"", 0, "", "pull " . )' +exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#PushComplete Gpush exe fugitive#Command(, , +"", 0, "", "push " . )' +exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#FetchComplete Gfetch exe fugitive#Command(, , +"", 0, "", "fetch " . )' +exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#BlameComplete Gblame exe fugitive#Command(, , +"", 0, "", "blame " . )' + exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(, 0)" exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(, 1)"