Use :Gsubcmd completion for :Git subcmd

This commit is contained in:
Tim Pope
2020-02-23 19:35:40 -05:00
parent 6b40e51008
commit aada6479cf

View File

@@ -2581,6 +2581,10 @@ function! fugitive#Complete(lead, ...) abort
let subcmd = matchstr(pre, '\u\w*[! ] *\zs[[:alnum:]-]\+\ze ') let subcmd = matchstr(pre, '\u\w*[! ] *\zs[[:alnum:]-]\+\ze ')
if empty(subcmd) if empty(subcmd)
let results = sort(s:Subcommands() + keys(s:Aliases(dir))) let results = sort(s:Subcommands() + keys(s:Aliases(dir)))
elseif a:0 ==# 2 && subcmd =~# '^\%(commit\|revert\|push\|fetch\|pull\|merge\|rebase\)$'
let cmdline = substitute(a:1, '\u\w*\([! ] *\)' . subcmd, 'G' . subcmd, '')
let caps_subcmd = substitute(subcmd, '\%(^\|-\)\l', '\u&', 'g')
return fugitive#{caps_subcmd}Complete(a:lead, cmdline, a:2 + len(cmdline) - len(a:1))
elseif pre =~# ' -- ' elseif pre =~# ' -- '
return fugitive#CompletePath(a:lead, dir) return fugitive#CompletePath(a:lead, dir)
elseif a:lead =~# '^-' elseif a:lead =~# '^-'