From 6ae7da9ecabb771bb2015c1df1557b87d2e2b7a1 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sat, 2 Apr 2022 17:21:23 +0530 Subject: [PATCH] nvim: autoload/git: Introduce a difftool version for git diff --- nvim/.config/nvim/after/ftplugin/git.vim | 1 + nvim/.config/nvim/autoload/git.vim | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/nvim/.config/nvim/after/ftplugin/git.vim b/nvim/.config/nvim/after/ftplugin/git.vim index 92cc9c4..08b38fe 100644 --- a/nvim/.config/nvim/after/ftplugin/git.vim +++ b/nvim/.config/nvim/after/ftplugin/git.vim @@ -5,6 +5,7 @@ nnoremap gB :call git#git_branch_delete() nnoremap gc :call git#git_cherry_pick() xnoremap gC :call git#git_cherry_pick_range() nnoremap gd :call git#git_diff_commit() +nnoremap gD :call git#git_difftool_commit() nnoremap gf :call git#git_format_patch() xnoremap gf :call git#git_format_patch_range() nnoremap gl :call git#git_branch_log() diff --git a/nvim/.config/nvim/autoload/git.vim b/nvim/.config/nvim/autoload/git.vim index 395f2f8..d095dd4 100644 --- a/nvim/.config/nvim/autoload/git.vim +++ b/nvim/.config/nvim/autoload/git.vim @@ -110,6 +110,15 @@ function! git#git_diff_commit() abort execute "Gtabedit | Git diff " . commit[1] . "^ " . commit[1] . "| only" endfunction +" Run Git difftool on the commit in the line which we are at. To be used after +" running some variation of Git log. +function! git#git_difftool_commit() abort + " A line in Git log is of the form commit + let line = trim(getline('.')) + let commit = split(line, " ") + execute "Gtabedit | Git difftool " . commit[1] . "^ " . commit[1] +endfunction + " To be used after running some variation of Git log. function! git#git_format_patch() abort " A line in Git log is of the form commit