commit 18fd27e2ccc6646db98e69d6c87e86bdccea16ff (tree)
parent fa5892dcace80677d894df659fdefe3ce617ceea
Author: Tim Pope <code@tpope.net>
Date: Fri, 27 Aug 2021 11:12:45 -0400
Provide slightly less bad "." map in temp buffers
Doing this right isn't on the horizon, so hack up something that's
better than nothing.
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -2946,6 +2946,22 @@ function! fugitive#Result(...) abort
endif
endfunction
+function! s:TempDotMap() abort
+ let cfile = s:cfile()
+ if empty(cfile)
+ return expand('<cword>')
+ endif
+ let name = fugitive#Find(cfile[0])
+ let [dir, commit, file] = s:DirCommitFile(name)
+ if len(commit) && empty(file)
+ return commit
+ elseif s:cpath(s:Tree(), getcwd())
+ return fugitive#Path(name, "./")
+ else
+ return fugitive#Real(name)
+ endif
+endfunction
+
function! s:TempReadPre(file) abort
if has_key(s:temp_files, s:cpath(a:file))
let dict = s:temp_files[s:cpath(a:file)]
@@ -2970,6 +2986,8 @@ function! s:TempReadPost(file) abort
endif
if get(dict, 'filetype', '') ==# 'git'
call fugitive#MapJumps()
+ call s:Map('n', '.', ":<C-U> <C-R>=<SID>fnameescape(<SID>TempDotMap())<CR><Home>")
+ call s:Map('x', '.', ":<C-U> <C-R>=<SID>fnameescape(<SID>TempDotMap())<CR><Home>")
endif
if has_key(dict, 'filetype')
if dict.filetype ==# 'man' && has('nvim')