-
-
Notifications
You must be signed in to change notification settings - Fork 218
How to use VimR as git difftool (with DirDiff.vim)
Tae Won Ha edited this page Mar 12, 2019
·
1 revision
When you use VimR as your git difftool
, you usually want to have the window maximized and all tools hidden. However, you don't want to have these settings persisted for your next normal VimR window for editing. You can achieve this by using some of the included commands in VimR.
Place the following in ~/.config/nvim/ginit.vim
function! s:VimRTempMaxWin() abort
VimRMakeSessionTemporary " The tools, tool buttons and window settings are not persisted
VimRHideTools
VimRMaximizeWindow
endfunction
command! -nargs=0 VimRTempMaxWin call s:VimRTempMaxWin()
and set your difftool
in ~/.gitconfig
[difftool "vimrdiff"]
cmd = vimr --wait --nvim '+au GUIEnter * execute \"DirDiff\" argv(0) argv(1)' '+au GUIEnter * VimRTempMaxWin' $LOCAL $REMOTE
[diff]
tool = vimrdiff
If you use DirDiff.vim, then you want to do the following in ~/.config/nvim/ginit.vim
function! s:VimRTempMaxWin() abort
VimRMakeSessionTemporary " The tools, tool buttons and window settings are not persisted
VimRHideTools
VimRMaximizeWindow
endfunction
command! -nargs=0 VimRTempMaxWin call s:VimRTempMaxWin()
function! s:VimRDifDiff() abort
VimRTempMaxWin
sleep 500m " Yes, ugly, but I could not find a better solution.
normal o " Select the first file (again) to resize the panes.
endfunction
command! -nargs=0 VimRDirDiff call s:VimRDirDiff()
and in ~/.gitconfig
[difftool "vimrdiff"]
cmd = vimr --wait --nvim '+au GUIEnter * execute \"DirDiff\" argv(0) argv(1)' '+au GUIEnter * VimRDirDiff' $LOCAL $REMOTE
[diff]
tool = vimrdiff