From 18fd27e2ccc6646db98e69d6c87e86bdccea16ff Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 27 Aug 2021 11:12:45 -0400 Subject: [PATCH] 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. --- autoload/fugitive.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index eb50d52..b25a6a2 100644 --- 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('') + 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', '.', ": =fnameescape(TempDotMap())") + call s:Map('x', '.', ": =fnameescape(TempDotMap())") endif if has_key(dict, 'filetype') if dict.filetype ==# 'man' && has('nvim')