mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-10 04:23:46 -05:00
Improve tab completion for :Git push
References: https://github.com/tpope/vim-fugitive/issues/1813
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user