nvim: autoload/git: Introduce a difftool version for git diff

This commit is contained in:
Sanchayan Maity 2022-04-02 17:21:23 +05:30
parent c95289343a
commit 6ae7da9eca
2 changed files with 10 additions and 0 deletions

View file

@ -5,6 +5,7 @@ nnoremap <buffer> <Leader>gB :call git#git_branch_delete()<CR>
nnoremap <buffer> <Leader>gc :call git#git_cherry_pick()<CR> nnoremap <buffer> <Leader>gc :call git#git_cherry_pick()<CR>
xnoremap <buffer> <Leader>gC :<C-U>call git#git_cherry_pick_range()<CR> xnoremap <buffer> <Leader>gC :<C-U>call git#git_cherry_pick_range()<CR>
nnoremap <buffer> <Leader>gd :call git#git_diff_commit()<CR> nnoremap <buffer> <Leader>gd :call git#git_diff_commit()<CR>
nnoremap <buffer> <Leader>gD :call git#git_difftool_commit()<CR>
nnoremap <buffer> <Leader>gf :call git#git_format_patch()<CR> nnoremap <buffer> <Leader>gf :call git#git_format_patch()<CR>
xnoremap <buffer> <Leader>gf :call git#git_format_patch_range()<CR> xnoremap <buffer> <Leader>gf :call git#git_format_patch_range()<CR>
nnoremap <buffer> <Leader>gl :call git#git_branch_log()<CR> nnoremap <buffer> <Leader>gl :call git#git_branch_log()<CR>

View file

@ -110,6 +110,15 @@ function! git#git_diff_commit() abort
execute "Gtabedit | Git diff " . commit[1] . "^ " . commit[1] . "| only" execute "Gtabedit | Git diff " . commit[1] . "^ " . commit[1] . "| only"
endfunction 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 <SHA>
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. " To be used after running some variation of Git log.
function! git#git_format_patch() abort function! git#git_format_patch() abort
" A line in Git log is of the form commit <SHA> " A line in Git log is of the form commit <SHA>