commit abefcb6ebd0f30ce9006a954c4cf463d6e6fa570 (tree)
parent 2c13dfff039ad58303c60b344a84d51629034202
Author: Tim Pope <code@tpope.net>
Date: Sun, 7 Jul 2019 12:46:44 -0400
Add --option completion to :Git
References https://github.com/tpope/vim-fugitive/issues/1265
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -1997,14 +1997,17 @@ endfunction
function! fugitive#CompleteGit(lead, ...) abort
let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir()
let pre = a:0 > 1 ? strpart(a:1, 0, a:2) : ''
- if pre !~# '\u\w*[! ] *[[:alnum:]-]\+ '
- let cmds = s:Subcommands()
- return filter(sort(cmds+keys(s:Aliases(dir))), 'strpart(v:val, 0, strlen(a:lead)) ==# a:lead')
+ let subcmd = matchstr(pre, '\u\w*[! ] *\zs[[:alnum:]-]\+\ze ')
+ if empty(subcmd)
+ let results = sort(s:Subcommands() + keys(s:Aliases(dir)))
elseif pre =~# ' -- '
return fugitive#CompletePath(a:lead, dir)
+ elseif a:lead =~# '^-'
+ let results = split(s:ChompDefault('', dir, subcmd, '--git-completion-helper'), ' ')
else
return fugitive#CompleteObject(a:lead, dir)
endif
+ return filter(results, 'strpart(v:val, 0, strlen(a:lead)) ==# a:lead')
endfunction
" Section: :Gcd, :Glcd