From 7d70992eae8605c16591abb0a8098a9f08f07310 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Thu, 10 Feb 2022 10:37:11 +0530 Subject: [PATCH] nvim: after/plugin/fugitive: Add mapping to help with review --- nvim/.config/nvim/after/plugin/fugitive.vim | 2 +- nvim/.config/nvim/autoload/git.vim | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/after/plugin/fugitive.vim b/nvim/.config/nvim/after/plugin/fugitive.vim index 2658aa2..2c9aaf0 100644 --- a/nvim/.config/nvim/after/plugin/fugitive.vim +++ b/nvim/.config/nvim/after/plugin/fugitive.vim @@ -23,7 +23,7 @@ nnoremap gM :call git#git_merge_origin() nnoremap gn :Git branch -m nnoremap go :call git#git_log_compare() nnoremap gr :call git#git_rebase_origin() -nnoremap gR :Git rebase --abort +nnoremap gR :call git#git_review() nnoremap g- :call git#git_stash():e nnoremap g+ :Git stash pop nnoremap gs :Git stash list diff --git a/nvim/.config/nvim/autoload/git.vim b/nvim/.config/nvim/autoload/git.vim index e34fc66..9457e12 100644 --- a/nvim/.config/nvim/autoload/git.vim +++ b/nvim/.config/nvim/autoload/git.vim @@ -242,6 +242,13 @@ function! git#git_rebase_origin() abort execute "Git rebase origin/" . default[3] endfunction +" Opens the output of Git diff main... in a tab for review +function! git#git_review() abort + let default = split(trim(system('git symbolic-ref refs/remotes/origin/HEAD')), '/') + let current = trim(system("git branch --show-current")) + execute "Gtabedit | Git diff " . default[3] . "..." . current . "| only" +endfunction + " Generate a helpful name when using Git stash function! git#git_stash() abort let current = trim(system("git branch --show-current"))