From d04c8675f9bbbbe6c435fc3688f30133a08c5ff4 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Fri, 2 Oct 2020 13:10:28 +0530 Subject: [PATCH] nvim: Switch back to gina dropping fugitive The only purposes we have been using fugitive for is status and commit which should be equally comfortable with gina. Gina log is really instantaneous even on big repositories like Linux while fugitive just freezes vim. For handling hunks, merge and rebase conflicts we anyways rely on the other plugins. We use edita so that applications which use $EDITOR internally can work inside neovim terminal without opening another instance which does not work with the already running instance. This is required for things like interactive rebase. See below issue. https://github.com/lambdalisue/gina.vim/issues/276 We drop fzf-checkout as it isn't that useful anymore since gina allows easy checkouts for branch or tags easily. --- nvim/.config/nvim/after/plugin/fugitive.vim | 21 --- .../nvim/after/plugin/fzf_checkout.vim | 9 -- nvim/.config/nvim/after/plugin/gina.vim | 145 ++++++++++++++++++ nvim/.config/nvim/init.vim | 4 +- 4 files changed, 147 insertions(+), 32 deletions(-) delete mode 100644 nvim/.config/nvim/after/plugin/fugitive.vim delete mode 100644 nvim/.config/nvim/after/plugin/fzf_checkout.vim create mode 100644 nvim/.config/nvim/after/plugin/gina.vim diff --git a/nvim/.config/nvim/after/plugin/fugitive.vim b/nvim/.config/nvim/after/plugin/fugitive.vim deleted file mode 100644 index 54f86b3..0000000 --- a/nvim/.config/nvim/after/plugin/fugitive.vim +++ /dev/null @@ -1,21 +0,0 @@ -nnoremap ga :Git fetch --all -nnoremap gl :0Gclog! -nnoremap gL :Gclog! -nnoremap gd :Ghdiffsplit! -nnoremap gD :Gvdiffsplit! -nnoremap gs :Git -nnoremap gS :Git -nnoremap gc :Git commit -v -q --signoff -nnoremap gC :Git commit -v -q --signoff %:p -nnoremap gp :Git push -nnoremap gP :Git push -u -nnoremap g- :Git stash:e -nnoremap g+ :Git stash pop:e -nnoremap gw :Gwrite -nnoremap gM :0,3Git blame -nnoremap gr :Git rebase origin/master -nnoremap gR :Git rebase upstream/master - -" For 3 way merge -nnoremap dl :diffget //2 -nnoremap dr :diffget //3 diff --git a/nvim/.config/nvim/after/plugin/fzf_checkout.vim b/nvim/.config/nvim/after/plugin/fzf_checkout.vim deleted file mode 100644 index e46e3cf..0000000 --- a/nvim/.config/nvim/after/plugin/fzf_checkout.vim +++ /dev/null @@ -1,9 +0,0 @@ -nnoremap gbo :GBranches checkout -nnoremap gbt :GBranches track -nnoremap gbc :GBranches create -nnoremap gbd :GBranches delete -nnoremap gbm :GBranches merge - -nnoremap gto :GTags checkout -nnoremap gtc :GTags create -nnoremap gtd :GTags delete diff --git a/nvim/.config/nvim/after/plugin/gina.vim b/nvim/.config/nvim/after/plugin/gina.vim new file mode 100644 index 0000000..9ca21d5 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/gina.vim @@ -0,0 +1,145 @@ +" Required for opening buffers vertically with gina-patch +set diffopt+=vertical + +nnoremap ga :Gina add %:p +nnoremap gb :Gina branch +nnoremap gB :Gina branch -a +nnoremap gc :Gina commit +nnoremap gC :Gina checkout -b +nnoremap gd :Gina diff -- % +nnoremap gD :Gina diff +nnoremap gf :Gina fetch --all +nnoremap gg :Gina +nnoremap gh :Gina patch +nnoremap gl :Gina log :% +nnoremap gL :Gina log +nnoremap gM :Gina merge +nnoremap gp :Gina push +nnoremap gP :Gina push --force-with-lease +nnoremap gr :Gina rebase origin/master +nnoremap gR :Gina remote -v +nnoremap gs :Gina status +nnoremap gt :Gina tag +nnoremap gT :Gina tag +nnoremap gu :Gina push -u +nnoremap g- :Gina stash:e +nnoremap g+ :Gina stash pop:e + +" Default options for the specific git commands +call gina#custom#command#option( + \ 'commit', '-v|--verbose' + \) +call gina#custom#command#option( + \ 'patch', '--oneside' + \) +call gina#custom#command#option( + \ 'patch', + \ '--opener', 'split' + \) +call gina#custom#command#option( + \ 'show', + \ '--opener', 'split', + \ '--show-signature' + \) +call gina#custom#command#option( + \ '/\%(status\|commit\)', + \ '-u|--untracked-files' + \) +call gina#custom#command#option( + \ 'status', + \ '-b|--branch' + \) +call gina#custom#command#option( + \ '/\%(branch\|commit\|diff\|log\|status\|tag\)', + \ '--opener', 'split' + \) +" Custom action aliases for gina buffers +call gina#custom#action#alias( + \ '/\%(blame\|log\|reflog\)', + \ 'preview', + \ 'belowright show:commit:preview', + \) +call gina#custom#action#alias( + \ '/\%(blame\|log\|reflog\)', + \ 'changes', + \ 'belowright changes:of:preview', + \) +" Custom key bindings in gina buffers +call gina#custom#mapping#nmap( + \ 'branch', 'bd', + \ ':call gina#action#call(''branch:delete'')', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ 'branch', 'br', + \ ':call gina#action#call(''branch:move:force'')', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ 'branch', 'su', + \ ':call gina#action#call(''branch:set-upstream-to'')', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ 'branch', 'uu', + \ ':call gina#action#call(''branch:unset-upstream'')', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ 'commit', 'gs', + \ ':Gina status', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ 'status', 'cc', + \ ':Gina commit', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ 'status', 'ga', + \ ':call gina#action#call(''add'')', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ '/\%(branch\|log\)', 'co', + \ ':call gina#action#call(''commit:checkout'')', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ '/\%(branch\|tag\)', 'ct', + \ ':call gina#action#call(''commit:checkout:track'')', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ '/\%(blame\|log\|reflog\)', + \ 'p', + \ ':call gina#action#call(''preview'')', + \ {'noremap': 1, 'silent': 1} + \) +call gina#custom#mapping#nmap( + \ '/\%(blame\|log\|reflog\)', + \ 'c', + \ ':call gina#action#call(''changes'')', + \ {'noremap': 1, 'silent': 1} + \) +" Set options for gina buffers +call gina#custom#execute( + \ '/\%(ls\|log\|reflog\|grep\)', + \ 'setlocal noautoread', + \) +call gina#custom#execute( + \ '/\%(status\|branch\|ls\|log\|reflog\|grep\)', + \ 'setlocal cursorline', + \) +call gina#custom#execute( + \ 'commit', + \ 'setlocal spell', + \) +call gina#custom#execute( + \ 'commit', + \ 'setlocal textwidth=72', + \) +call gina#custom#execute( + \ 'log', + \ 'setlocal number', + \) diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 93f82cf..72b4ecf 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -18,12 +18,11 @@ Plug 'steelsojka/completion-buffers' " For tmux Plug 'tmux-plugins/vim-tmux-focus-events' " Git support +Plug 'lambdalisue/gina.vim' Plug 'rhysd/git-messenger.vim' -Plug 'tpope/vim-fugitive' Plug 'mhinz/vim-signify' Plug 'rhysd/conflict-marker.vim' Plug 'salcode/vim-interactive-rebase-reverse' -Plug 'stsewd/fzf-checkout.vim' " Boost vim command line mode Plug 'vim-utils/vim-husk' " Rainbow Parentheses @@ -63,6 +62,7 @@ Plug 'liuchengxu/vim-which-key' Plug 'christoomey/vim-system-copy' " Toggle terminal Plug 'voldikss/vim-floaterm' +Plug 'lambdalisue/edita.vim' " Take care of sudo Plug 'lambdalisue/suda.vim' " LSP