nvim: after/plugin/fugitive: Add mapping to help with review

This commit is contained in:
Sanchayan Maity 2022-02-10 10:37:11 +05:30
parent 05bbba29a9
commit 7d70992eae
2 changed files with 8 additions and 1 deletions

View file

@ -23,7 +23,7 @@ nnoremap <Leader>gM :call git#git_merge_origin()<CR>
nnoremap <Leader>gn :Git branch -m<SPACE> nnoremap <Leader>gn :Git branch -m<SPACE>
nnoremap <Leader>go :call git#git_log_compare()<CR> nnoremap <Leader>go :call git#git_log_compare()<CR>
nnoremap <Leader>gr :call git#git_rebase_origin()<CR> nnoremap <Leader>gr :call git#git_rebase_origin()<CR>
nnoremap <Leader>gR :Git rebase --abort<CR> nnoremap <Leader>gR :call git#git_review()<CR>
nnoremap <Leader>g- :call git#git_stash()<CR>:e<CR> nnoremap <Leader>g- :call git#git_stash()<CR>:e<CR>
nnoremap <Leader>g+ :Git stash pop<SPACE> nnoremap <Leader>g+ :Git stash pop<SPACE>
nnoremap <Leader>gs :Git stash list<CR> nnoremap <Leader>gs :Git stash list<CR>

View file

@ -242,6 +242,13 @@ function! git#git_rebase_origin() abort
execute "Git rebase origin/" . default[3] execute "Git rebase origin/" . default[3]
endfunction endfunction
" Opens the output of Git diff main...<current_branch> 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 " Generate a helpful name when using Git stash
function! git#git_stash() abort function! git#git_stash() abort
let current = trim(system("git branch --show-current")) let current = trim(system("git branch --show-current"))