motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit 8cf3d94a3adff7ee9468a1c396d0ae1ecfce9c91 (tree)
parent 28de2a1ddd41d6fb77d32550c6b07f91b6f2dfbe
Author: Tim Pope <code@tpope.net>
Date:   Wed,  7 Oct 2015 00:03:06 -0400

Support gf in git filetypes

Closes https://github.com/tpope/vim-fugitive/issues/697

Diffstat:
Mplugin/fugitive.vim | 28+++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)

diff --git 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 <SID>: :<C-U><C-R>=v:count ? v:count : ''<CR> +function! s:GFInit(...) abort + cnoremap <buffer> <expr> <Plug><cfile> fugitive#cfile() + if !exists('g:fugitive_no_maps') && empty(mapcheck('gf', 'n')) + nmap <buffer> <silent> gf <SID>:find <Plug><cfile><CR> + nmap <buffer> <silent> <C-W>f <SID>:sfind <Plug><cfile><CR> + nmap <buffer> <silent> <C-W><C-F> <SID>:sfind <Plug><cfile><CR> + nmap <buffer> <silent> <C-W>gf <SID>:tabfind <Plug><cfile><CR> + endif +endfunction + +function! s:JumpInit(...) abort nnoremap <buffer> <silent> <CR> :<C-U>exe <SID>GF("edit")<CR> if !&modifiable nnoremap <buffer> <silent> o :<C-U>exe <SID>GF("split")<CR> @@ -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('<cfile>') + 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