Expose completion helpers for subcommands

This commit is contained in:
Tim Pope
2019-09-08 18:09:44 -04:00
parent f5fc469c0c
commit 35f1095f9b

View File

@@ -3335,7 +3335,7 @@ function! s:RevertSubcommand(line1, line2, range, bang, mods, args) abort
return s:CommitSubcommand(a:line1, a:line2, a:range, a:bang, a:mods, [], dir)
endfunction
function! s:CommitComplete(A, L, P) abort
function! fugitive#CommitComplete(A, L, P) abort
if a:A =~# '^--fixup=\|^--squash='
let commits = s:LinesError(['log', '--pretty=format:%s', '@{upstream}..'])[0]
let pre = matchstr(a:A, '^--\w*=''\=') . ':/^'
@@ -3352,7 +3352,7 @@ function! s:CommitComplete(A, L, P) abort
return []
endfunction
function! s:RevertComplete(A, L, P) abort
function! fugitive#RevertComplete(A, L, P) abort
return s:CompleteSub('revert', a:A, a:L, a:P, function('s:CompleteRevision'))
endfunction
@@ -3370,20 +3370,20 @@ function! s:FinishCommit() abort
return ''
endfunction
call s:command("-nargs=? -range=-1 -complete=customlist,s:CommitComplete Gcommit", "commit")
call s:command("-nargs=? -range=-1 -complete=customlist,s:RevertComplete Grevert", "revert")
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! s:MergeComplete(A, L, P) abort
function! fugitive#MergeComplete(A, L, P) abort
return s:CompleteSub('merge', a:A, a:L, a:P, function('s:CompleteRevision'))
endfunction
function! s:RebaseComplete(A, L, P) abort
function! fugitive#RebaseComplete(A, L, P) abort
return s:CompleteSub('rebase', a:A, a:L, a:P, function('s:CompleteRevision'))
endfunction
function! s:PullComplete(A, L, P) abort
function! fugitive#PullComplete(A, L, P) abort
return s:CompleteSub('pull', a:A, a:L, a:P, function('s:CompleteRemote'))
endfunction
@@ -3650,9 +3650,9 @@ augroup fugitive_merge
\ endif
augroup END
call s:command("-nargs=? -bang -complete=customlist,s:MergeComplete Gmerge", "merge")
call s:command("-nargs=? -bang -complete=customlist,s:RebaseComplete Grebase", "rebase")
call s:command("-nargs=? -bang -complete=customlist,s:PullComplete Gpull", "pull")
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
@@ -4203,11 +4203,11 @@ augroup END
" Section: :Gpush, :Gfetch
function! s:PushComplete(A, L, P) abort
function! fugitive#PushComplete(A, L, P) abort
return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompleteRemote'))
endfunction
function! s:FetchComplete(A, L, P) abort
function! fugitive#FetchComplete(A, L, P) abort
return s:CompleteSub('fetch', a:A, a:L, a:P, function('s:CompleteRemote'))
endfunction
@@ -4260,8 +4260,8 @@ 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,s:PushComplete Gpush", "push")
call s:command("-nargs=? -bang -complete=customlist,s:FetchComplete Gfetch", "fetch")
call s:command("-nargs=? -bang -complete=customlist,fugitive#PushComplete Gpush", "push")
call s:command("-nargs=? -bang -complete=customlist,fugitive#FetchComplete Gfetch", "fetch")
" Section: :Gdiff
@@ -4667,7 +4667,7 @@ function! s:BlameQuit() abort
endif
endfunction
function! s:BlameComplete(A, L, P) abort
function! fugitive#BlameComplete(A, L, P) abort
return s:CompleteSub('blame', a:A, a:L, a:P)
endfunction
@@ -5093,7 +5093,7 @@ augroup fugitive_blame
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
augroup END
call s:command('-buffer -bang -range=-1 -nargs=? -complete=customlist,s:BlameComplete Gblame', 'blame')
call s:command('-buffer -bang -range=-1 -nargs=? -complete=customlist,fugitive#BlameComplete Gblame', 'blame')
" Section: :Gbrowse