From 2c6bd3bd2d577ccebe773ca1ae47d0ce0ebcc02d Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 20 Aug 2021 11:47:18 -0400 Subject: [PATCH] Improve tab completion for :Git push References: https://github.com/tpope/vim-fugitive/issues/1813 --- autoload/fugitive.vim | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 348e151..79a635c 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -5841,8 +5841,24 @@ endfunction " Section: :Git push, :Git fetch +function! s:CompletePush(A, L, P, ...) abort + let dir = a:0 ? a:1 : s:Dir() + let remote = matchstr(a:L, '\u\w*[! ] *.\{-\}\s\@<=\zs[^-[:space:]]\S*\ze ') + if empty(remote) + let matches = s:LinesError([dir, 'remote'])[0] + elseif a:A =~# ':' + let lead = matchstr(a:A, '^[^:]*:') + let matches = s:LinesError([dir, 'ls-remote', remote])[0] + call filter(matches, 'v:val =~# "\t" && v:val !~# "{"') + call map(matches, 'lead . s:sub(v:val, "^.*\t", "")') + else + let matches = s:CompleteHeads(dir) + endif + return s:FilterEscape(matches, a:A) +endfunction + function! fugitive#PushComplete(A, L, P, ...) abort - return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompleteRemote'), a:000) + return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompletePush'), a:000) endfunction function! fugitive#FetchComplete(A, L, P, ...) abort