Open cpmsmith opened 3 months ago
Need some more testing, but this should do the trick.
diff --git a/plug.vim b/plug.vim
index 940811a..4c3a081 100644
--- a/plug.vim
+++ b/plug.vim
@@ -2683,6 +2683,11 @@ function! s:preview_commit()
return
endif
+ let use_fugitive = exists('*FugitiveFind') && len(sha)
+ if use_fugitive
+ let title = FugitiveFind(sha, g:plugs[name].dir . '/.git')
+ endif
+
if !s:is_preview_window_open()
execute get(g:, 'plug_pwindow', 'vertical rightbelow new')
execute 'e' title
@@ -2691,6 +2696,12 @@ function! s:preview_commit()
wincmd P
endif
setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable
+ nnoremap <silent> <buffer> q :q<cr>
+ if use_fugitive
+ wincmd p
+ return
+ endif
+
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
@@ -2706,7 +2717,6 @@ function! s:preview_commit()
endif
endtry
setlocal nomodifiable
- nnoremap <silent> <buffer> q :q<cr>
wincmd p
endfunction
The patch works. But it's considerably slower to open a commit, so users who don't need additional features of Fugitive may not like it.
In
:PlugDiff
, it's possible to hit enter on a given commit to view its content:fugitive.vim has a very similar feature for viewing commits, but with extra features like being able to browse to other commits and files, and with rhubarb.vim and others, to open the equivalent forge URL e.g. on GitHub.
It'd be cool if vim-plug used fugitive to view commits when it's available.