nvim: fugitive: Add mapping to view file on another branch

This commit is contained in:
Sanchayan Maity 2024-11-27 11:56:05 +05:30
parent 036b6652a9
commit bcfd9372dc
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3
2 changed files with 6 additions and 0 deletions

View file

@ -36,6 +36,7 @@ nnoremap <Leader>G :keepalt Git<SPACE>
nnoremap <Leader>gp :call git#git_push_to_upstream()<CR>
nnoremap <expr> <Leader>gP git#git_push()
nnoremap <expr> <Leader>gO git#git_show_file_on_branch()
augroup custom_fugitive
autocmd!

View file

@ -289,6 +289,11 @@ function! git#git_review_fileview() abort
execute "Git difftool -y " . default[3] . "..." . current
endfunction
" Show file on another branch without changing current branch
function! git#git_show_file_on_branch() abort
return ":Git show :" . expand("%")
endfunction
" Generate a helpful name when using Git stash
function! git#git_stash() abort
let current = trim(system("git branch --show-current"))