From 9e18f6db165a8782c54c3f7a9a1d4feb3efb10b8 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 13 May 2022 18:33:57 +0200 Subject: [PATCH] vim:keys: Make git mappings fugitive independent Make the git {add,stash,checkout} mappings independent of fugitive.vim. --- .config/vim/vimrc.d/40-keys.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index a6e71ff..4aa57b5 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -111,17 +111,21 @@ vnoremap # y?\V=escape(@",'?\') nnoremap gp '`[' . strpart(getregtype(), 0, 1) . '`]' " Git bindings + " Insert a commit's subject behind the SHA1 that the cursor is currently on. " Mnemonic: "git reference commit" " NOTE: This uses `system` and not `:r!` to insert the text directly at the " cursor. `subject[:-2]` cuts off the trailing newline. nmap grc :let subject=system('git show -s --format="(\"%s\")" ')ea =subject[:-2] -if exists('g:loaded_fugitive') - nmap gc :G commit - nmap ga :G add -- % - nmap gs :G stash -- % - nmap gu :G checkout -- % +" Add, stash or checkout the current file +nmap ga :!git add -- % +nmap gs :!git stash -- % +nmap gu :!git checkout -- % + +if exists('g:loaded_fugitive') + " Using fugitive.vim, start a commit and open the message in a new split + nmap gc :G commit else " only works if a file is already opened nnoremap gcd :cd %:h cd `git rev-parse --show-toplevel`