From abefcb6ebd0f30ce9006a954c4cf463d6e6fa570 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 7 Jul 2019 12:46:44 -0400 Subject: [PATCH] Add --option completion to :Git References https://github.com/tpope/vim-fugitive/issues/1265 --- autoload/fugitive.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index e7f2294..80ed98c 100644 --- 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