From: Samir Benmendil Date: Thu, 9 Jun 2022 13:16:04 +0000 (+0100) Subject: vim: map \gs to GitToggle X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/d001cf9213aebde421dacfcbe3101dade4db9c51?ds=inline vim: map \gs to GitToggle --- diff --git a/vim/vimrc b/vim/vimrc index f57d3d1..fdd0552 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -612,7 +612,18 @@ nmap dd :tab split \| Gdiff \| wincmd h " delete fugitive buffers when closed autocmd BufReadPost fugitive://* set bufhidden=delete -nnoremap gs :Git +function! GitToggle() + if buflisted(bufname('.git/index')) + bdelete .git/index + else + Git + 16wincmd_ + endif +endfunction +command! GitToggle :call GitToggle() +command! GToggle GitToggle +nnoremap gs :GitToggle + nnoremap gd :Gdiffsplit nnoremap gc :echohl WarningMsg \| echo "use \gcc instead" \| echohl None nnoremap gcc :tab G commit -v