From f56bb8c5fb024caf9a1e98358191b5dfc3a3a13a Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sat, 25 Apr 2020 13:07:49 +0530 Subject: [PATCH] nvim: Drop vim-fugitive and move to gina vim-fugitive from Tpope is synchronous on neovim. It is asynchronous on vim when vim-dispatch is available but for neovim it will always be synchronous. Gina is asynchronous by default and does not freeze on large repos like fugitive does. So drop fugitive, other plugins and settings dependent on it. While at it, also add some more good things from git gutter and some shortcuts. Signed-off-by: Sanchayan Maity --- nvim/.config/nvim/init.vim | 106 +++++++++++++++++------- nvim/.config/nvim/plugin/statusline.vim | 10 --- 2 files changed, 78 insertions(+), 38 deletions(-) diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 5b5b405..ce02b65 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -27,18 +27,12 @@ Plug 'tmux-plugins/vim-tmux-focus-events' Plug 'wellle/tmux-complete.vim' " For LaTeX support Plug 'lervag/vimtex' -" Primary git support -Plug 'tpope/vim-fugitive' -" Manage git hunks +" Git support +Plug 'lambdalisue/gina.vim' Plug 'airblade/vim-gitgutter' -" Git blame Plug 'rhysd/git-messenger.vim' -" Git logs -Plug 'rbong/vim-flog' -" Handle merge conflicts Plug 'samoshkin/vim-mergetool' -" Git diffs in quickfix list -Plug 'oguzbilgic/vim-gdiff' +Plug 'whiteinge/diffconflicts' " Boost vim command line mode Plug 'vim-utils/vim-husk' " GDB @@ -118,7 +112,7 @@ let maplocalleader="," set colorcolumn=80 " Highlight 80th column set laststatus=2 " Always show status bar -set updatetime=300 " Let plugins show effects after 500ms +set updatetime=100 " Let plugins show effects after 100ms set mouse-=a " Disable mouse click to go to position set encoding=utf-8 set exrc " Allow loading local .nvimrc files @@ -219,6 +213,7 @@ nnoremap fo :Locate nnoremap fk :Maps nnoremap f/ :Rg nnoremap fs :exe ':Rg ' . expand('') +nnoremap fg :GGrep imap (fzf-complete-word) imap (fzf-complete-path) imap (fzf-complete-file) @@ -246,24 +241,27 @@ nnoremap [s :FloatermPrev nnoremap ]s :FloatermNext nnoremap st :FloatermToggle " For git -nnoremap gm :GitMessenger -nnoremap gl :0Glog -nnoremap gL :Glog -nnoremap gd :Gdiff -nnoremap gD :Gdiffsplit -nnoremap gs :Gstatus -nnoremap gc :Gcommit -v -q --signoff -nnoremap gt :Gcommit -v -q --signoff %:p -nnoremap gp :Git push -nnoremap gu :Git push -u -nnoremap gr :Git remote -v -nnoremap gb :Git branch -nnoremap go :Git checkout -nnoremap g- :Git stash:e -nnoremap g+ :Git stash pop:e -nnoremap gG :exe ':Ggrep ' . expand('') -nnoremap gF :Ggrep -nnoremap gg :GGrep +nnoremap gm :GitMessenger +nnoremap glh :Gina log --opener=split +nnoremap glv :Gina log --opener=vsplit +nnoremap gL :Gina log +nnoremap gdh :Gina diff --opener=split +nnoremap gdv :Gina diff --opener=split +nnoremap gD :Gina diff +nnoremap gs :Gina! status +nnoremap ghs :Gina status --opener=split +nnoremap gvs :Gina status --opener=vsplit +nnoremap gc :Gina commit -v -q --signoff +nnoremap gt :Gina commit -v -q --signoff %:p +nnoremap gp :Gina push +nnoremap gu :Gina push -u +nnoremap gr :Gina remote -v +nnoremap gb :Gina! branch +nnoremap gB :Gina branch +nnoremap go :Gina checkout +nnoremap g- :Gina stash:e +nnoremap g+ :Gina stash +" Git merge tool nnoremap ml :MergetoolDiffExchangeLeft nnoremap mr :MergetoolDiffExchangeRight nnoremap mu :MergetoolDiffExchangeUp @@ -273,11 +271,20 @@ nnoremap mp :diffput " For gitgutter nnoremap ]h :GitGutterNextHunk nnoremap [h :GitGutterPrevHunk +nnoremap ]c :call NextHunkAllBuffers() +nnoremap [c :call PrevHunkAllBuffers() nnoremap sh :GitGutterStageHunk nnoremap uh :GitGutterUndoHunk nnoremap ph :GitGutterPreviewHunk nnoremap qh :GitGutterQuickFix nnoremap gf :GitGutterFold +omap ih (GitGutterTextObjectInnerPending) +omap ah (GitGutterTextObjectOuterPending) +xmap ih (GitGutterTextObjectInnerVisual) +xmap ah (GitGutterTextObjectOuterVisual) +" Jump to sections of diff +nnoremap { ?^@@ +nnoremap } /^@@ " For Neomake/Neoformat nnoremap nm :Neomake nnoremap nc :NeomakeClean @@ -538,3 +545,46 @@ function! s:incsearch_config(...) abort \ 'is_expr': 0 \ }), get(a:, 1, {})) endfunction + +" Taken from gitgutter README. Cycles through all hunks in all open buffers. +function! NextHunkAllBuffers() + let line = line('.') + GitGutterNextHunk + if line('.') != line + return + endif + + let bufnr = bufnr('') + while 1 + bnext + if bufnr('') == bufnr + return + endif + if !empty(GitGutterGetHunks()) + 1 + GitGutterNextHunk + return + endif + endwhile +endfunction + +function! PrevHunkAllBuffers() + let line = line('.') + GitGutterPrevHunk + if line('.') != line + return + endif + + let bufnr = bufnr('') + while 1 + bprevious + if bufnr('') == bufnr + return + endif + if !empty(GitGutterGetHunks()) + normal! G + GitGutterPrevHunk + return + endif + endwhile +endfunction diff --git a/nvim/.config/nvim/plugin/statusline.vim b/nvim/.config/nvim/plugin/statusline.vim index 03b7a9c..4057933 100644 --- a/nvim/.config/nvim/plugin/statusline.vim +++ b/nvim/.config/nvim/plugin/statusline.vim @@ -13,14 +13,6 @@ hi User6 guifg=Gray guibg=Black hi User7 guifg=Gray guibg=Black hi User8 guifg=DarkYellow guibg=Black -function! GitInfo() - let git = fugitive#head() - if git != '' - return ' '.fugitive#head() - else - return '' -endfunction - " https://nest.pijul.com/tae/setup:master/ function! GetCursorPosition() if &buftype == '' @@ -59,7 +51,6 @@ endfunction function! ActiveStatus() abort let statusline="" let statusline.="%1*\ %{winnr()}\ " - let statusline.="%2*\ %{GitInfo()}" let statusline.="%4*\ %{GitHunkStatus()}" let statusline.="%2*\ %Y\ " let statusline.="%3*%<%{GetFileDir()}" @@ -71,7 +62,6 @@ endfunction function! PassiveStatus() abort let statusline="" let statusline.="%5*\ %{winnr()}\ " - let statusline.="%6*\ %{GitInfo()}" let statusline.="%8*\ %{GitHunkStatus()}" let statusline.="%6*\ %Y\ " let statusline.="%7*%<%{GetFileDir()}"