diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index b5d2398..af4d088 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -2696,6 +2696,10 @@ augroup fugitive_files \ if exists('b:git_dir') | \ call s:JumpInit() | \ endif + autocmd FileType git,gitcommit,gitrebase + \ if exists('b:git_dir') | + \ call s:GFInit() | + \ endif augroup END " Section: Temp files @@ -2719,7 +2723,18 @@ augroup END " Section: Go to file -function! s:JumpInit() abort +nnoremap : :=v:count ? v:count : '' +function! s:GFInit(...) abort + cnoremap fugitive#cfile() + if !exists('g:fugitive_no_maps') && empty(mapcheck('gf', 'n')) + nmap gf :find + nmap f :sfind + nmap :sfind + nmap gf :tabfind + endif +endfunction + +function! s:JumpInit(...) abort nnoremap :exe GF("edit") if !&modifiable nnoremap o :exe GF("split") @@ -2928,6 +2943,17 @@ function! s:GF(mode) abort endif endfunction +function! fugitive#cfile() abort + let pre = '' + let results = s:cfile() + if empty(results) + return expand('') + elseif len(results) > 1 + let pre = '+' . join(map(results[1:-1], 'escape(v:val, " ")'), '\|') . ' ' + endif + return pre . s:fnameescape(fugitive#repo().translate(results[0])) +endfunction + " Section: Statusline function! s:repo_head_ref() dict abort