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 <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-04-25 13:07:49 +05:30
parent d879a43b48
commit f56bb8c5fb
2 changed files with 78 additions and 38 deletions

View file

@ -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 <Leader>fo :Locate<SPACE>
nnoremap <Leader>fk :Maps<CR>
nnoremap <Leader>f/ :Rg<CR>
nnoremap <Leader>fs :exe ':Rg ' . expand('<cword>')<CR>
nnoremap <Leader>fg :GGrep<SPACE>
imap <C-x><C-w> <Plug>(fzf-complete-word)
imap <C-x><C-p> <Plug>(fzf-complete-path)
imap <C-x><C-f> <Plug>(fzf-complete-file)
@ -247,23 +242,26 @@ nnoremap ]s :FloatermNext<CR>
nnoremap st :FloatermToggle<CR>
" For git
nnoremap <Leader>gm :GitMessenger<CR>
nnoremap <Leader>gl :0Glog<CR>
nnoremap <Leader>gL :Glog<CR>
nnoremap <Leader>gd :Gdiff<CR>
nnoremap <Leader>gD :Gdiffsplit<CR>
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gc :Gcommit -v -q --signoff<CR>
nnoremap <Leader>gt :Gcommit -v -q --signoff %:p<CR>
nnoremap <Leader>gp :Git push<CR>
nnoremap <Leader>gu :Git push -u<SPACE>
nnoremap <Leader>gr :Git remote -v<CR>
nnoremap <Leader>gb :Git branch<SPACE>
nnoremap <Leader>go :Git checkout<SPACE>
nnoremap <Leader>g- :Git stash<CR>:e<CR>
nnoremap <Leader>g+ :Git stash pop<CR>:e<CR>
nnoremap <Leader>gG :exe ':Ggrep ' . expand('<cword>')<CR>
nnoremap <Leader>gF :Ggrep<SPACE>
nnoremap <Leader>gg :GGrep<SPACE>
nnoremap <Leader>glh :Gina log --opener=split<CR>
nnoremap <Leader>glv :Gina log --opener=vsplit<CR>
nnoremap <Leader>gL :Gina log<SPACE>
nnoremap <Leader>gdh :Gina diff --opener=split<CR>
nnoremap <Leader>gdv :Gina diff --opener=split<CR>
nnoremap <Leader>gD :Gina diff<SPACE>
nnoremap <Leader>gs :Gina! status<CR>
nnoremap <Leader>ghs :Gina status --opener=split<CR>
nnoremap <Leader>gvs :Gina status --opener=vsplit<CR>
nnoremap <Leader>gc :Gina commit -v -q --signoff<CR>
nnoremap <Leader>gt :Gina commit -v -q --signoff %:p<CR>
nnoremap <Leader>gp :Gina push<CR>
nnoremap <Leader>gu :Gina push -u<SPACE>
nnoremap <Leader>gr :Gina remote -v<CR>
nnoremap <Leader>gb :Gina! branch<CR>
nnoremap <Leader>gB :Gina branch<SPACE>
nnoremap <Leader>go :Gina checkout<SPACE>
nnoremap <Leader>g- :Gina stash<CR>:e<CR>
nnoremap <Leader>g+ :Gina stash<SPACE>
" Git merge tool
nnoremap <Leader>ml :MergetoolDiffExchangeLeft<CR>
nnoremap <Leader>mr :MergetoolDiffExchangeRight<CR>
nnoremap <Leader>mu :MergetoolDiffExchangeUp<CR>
@ -273,11 +271,20 @@ nnoremap <Leader>mp :diffput<CR>
" For gitgutter
nnoremap ]h :GitGutterNextHunk<CR>
nnoremap [h :GitGutterPrevHunk<CR>
nnoremap ]c :call NextHunkAllBuffers()<CR>
nnoremap [c :call PrevHunkAllBuffers()<CR>
nnoremap <Leader>sh :GitGutterStageHunk<CR>
nnoremap <Leader>uh :GitGutterUndoHunk<CR>
nnoremap <Leader>ph :GitGutterPreviewHunk<CR>
nnoremap <Leader>qh :GitGutterQuickFix<CR>
nnoremap <Leader>gf :GitGutterFold<CR>
omap ih <Plug>(GitGutterTextObjectInnerPending)
omap ah <Plug>(GitGutterTextObjectOuterPending)
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
" Jump to sections of diff
nnoremap { ?^@@<CR>
nnoremap } /^@@<CR>
" For Neomake/Neoformat
nnoremap <Leader>nm :Neomake<CR>
nnoremap <Leader>nc :NeomakeClean<CR>
@ -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

View file

@ -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()}"