diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 60403bd..064ed46 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2526,7 +2526,7 @@ function! fugitive#BufReadStatus() abort if &bufhidden ==# '' setlocal bufhidden=delete endif - call s:JumpInit() + call fugitive#MapJumps() nunmap P nunmap ~ nnoremap :execute StageNext(v:count1) @@ -2707,7 +2707,7 @@ function! fugitive#BufReadObject() abort nnoremap a :let b:fugitive_display_format += v:count1exe BufReadObject() nnoremap i :let b:fugitive_display_format -= v:count1exe BufReadObject() else - call s:JumpInit() + call fugitive#MapJumps() endif endtry @@ -2721,14 +2721,6 @@ endfunction augroup fugitive_files autocmd! - autocmd FileType git - \ 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 @@ -2753,7 +2745,7 @@ augroup END " Section: Go to file nnoremap : :=v:count ? v:count : '' -function! s:GFInit(...) abort +function! fugitive#MapCfile(...) abort cnoremap fugitive#Cfile() if !exists('g:fugitive_no_maps') call s:map('n', 'gf', ':find ', '') @@ -2764,7 +2756,7 @@ function! s:GFInit(...) abort endif endfunction -function! s:JumpInit(...) abort +function! fugitive#MapJumps(...) abort nnoremap :exe GF("edit") if !&modifiable nnoremap o :exe GF("split") diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 8ca07bc..22ecb28 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -156,6 +156,15 @@ augroup fugitive autocmd VimEnter * if expand('')==''|call FugitiveDetect(getcwd())|endif autocmd CmdWinEnter * call FugitiveDetect(expand('#:p')) + autocmd FileType git + \ if exists('b:git_dir') | + \ call fugitive#MapJumps() | + \ endif + autocmd FileType git,gitcommit,gitrebase + \ if exists('b:git_dir') | + \ call fugitive#MapCfile() | + \ endif + autocmd BufReadCmd index{,.lock} \ if FugitiveIsGitDir(expand(':p:h')) | \ exe fugitive#BufReadStatus() |