nvim: init.vim: Use vim-unimpaired & improve bindings

unimpaired provides some helpful bindings so use that. Remove redundant
bindings like the ones for quickfix & location list due to use of
unimpaired. It also provides consistent bindings across the board.

While at it, reduce the use of leader key. The idea behind using leader
key everywhere was taken since we migrated from spacemacs, However, for
non-conflicting bindings it's better to have a hit as few keys as
possible, so remove leader from few of the earlier bindings.

To see list of all mappings, use '9verbose nmap <key>'.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2019-12-30 16:29:11 +05:30
parent df07def242
commit 4ebc8f3788

View file

@ -89,6 +89,7 @@ Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-unimpaired'
Plug 'editorconfig/editorconfig-vim'
Plug 'igankevich/mesonic'
Plug 'stefandtw/quickfix-reflector.vim'
@ -206,23 +207,23 @@ nnoremap ; :
nnoremap Q <Nop>
" For Fuzzy
nnoremap <Leader>vf :GFiles<CR>
nnoremap <Leader>v? :GFiles?<CR>
nnoremap <Leader>vF :Files<CR>
nnoremap <Leader>vb :Buffers<CR>
nnoremap <Leader>vL :Lines<CR>
nnoremap <Leader>vl :BLines<CR>
nnoremap <Leader>vt :BTags<CR>
nnoremap <Leader>vT :Tags<CR>
nnoremap <Leader>vc :BCommits<CR>
nnoremap <Leader>vC :Commits<CR>
nnoremap <Leader>vch :History:<CR>
nnoremap <Leader>vsh :History/<CR>
nnoremap <Leader>vm :Commands<CR>
nnoremap <Leader>vo :Locate<SPACE>
nnoremap <Leader>vk :Maps<CR>
nnoremap <Leader>v/ :Rg<CR>
nnoremap <Leader>* :exe ':Rg ' . expand('<cword>')<CR>
nnoremap ff :GFiles<CR>
nnoremap f? :GFiles?<CR>
nnoremap fF :Files<CR>
nnoremap fb :Buffers<CR>
nnoremap fL :Lines<CR>
nnoremap fl :BLines<CR>
nnoremap ft :BTags<CR>
nnoremap fT :Tags<CR>
nnoremap fc :BCommits<CR>
nnoremap fC :Commits<CR>
nnoremap fch :History:<CR>
nnoremap fsh :History/<CR>
nnoremap fm :Commands<CR>
nnoremap fo :Locate<SPACE>
nnoremap fk :Maps<CR>
nnoremap f/ :Rg<CR>
nnoremap * :exe ':Rg ' . expand('<cword>')<CR>
" Quick buffer switching
nnoremap <Leader>b :ls<CR>:b<Space>
" Undo tree
@ -236,19 +237,15 @@ nnoremap <Leader>sh <Esc>:sp<CR>
nnoremap <Leader>sv <Esc>:vsp<CR>
" Quit
nnoremap <Leader>x <Esc>:x<CR>
nnoremap <Leader>q <Esc>:q<CR>
nnoremap <Leader>Q <Esc>:qa<CR>
" Terminal
nnoremap <Leader>te :vsp<CR> :terminal<CR>
nnoremap <Leader>tc :SlimeConfig<CR>
xmap <Leader>ts <Plug>SlimeRegionSend
nmap <Leader>ts <Plug>SlimeParagraphSend
" Tab navigation shortcuts
nnoremap <Leader>tn :bn<CR>
nnoremap <Leader>tp :bp<CR>
nnoremap <PageUp> :bprevious<CR>
nnoremap <PageDown> :bnext<CR>
" Reload opened vim config file
nnoremap <Leader>vr :so %<CR>
nnoremap <Leader>r :so %<CR>
" For git
nnoremap <Leader>gm :GitMessenger<CR>
nnoremap <Leader>gl :0Glog<CR>
@ -269,38 +266,32 @@ nnoremap <Leader>gf :exe ':Ggrep ' . expand('<cword>')<CR>
nnoremap <Leader>gF :Ggrep<SPACE>
nnoremap <Leader>gg :GGrep<SPACE>
" For gitgutter
nnoremap <Leader>ghn :GitGutterNextHunk<CR>
nnoremap <Leader>ghp :GitGutterPrevHunk<CR>
nnoremap <Leader>ghs :GitGutterStageHunk<CR>
nnoremap <Leader>ghu :GitGutterUndoHunk<CR>
nnoremap <Leader>ghr :GitGutterPreviewHunk<CR>
nnoremap <Leader>gqf :GitGutterQuickFix<CR>
nnoremap <Leader>ggf :GitGutterFold<CR>
nnoremap un :GitGutterNextHunk<CR>
nnoremap up :GitGutterPrevHunk<CR>
nnoremap us :GitGutterStageHunk<CR>
nnoremap ud :GitGutterUndoHunk<CR>
nnoremap ur :GitGutterPreviewHunk<CR>
nnoremap uq :GitGutterQuickFix<CR>
nnoremap uf :GitGutterFold<CR>
" For Neomake/Neoformat
nnoremap <Leader>nm :Neomake<CR>
nnoremap <Leader>nc :NeomakeClean<CR>
nnoremap <Leader>ns :NeomakeSh<SPACE>
nnoremap <Leader>njl :NeomakeListJobs<CR>
nnoremap <Leader>nja :NeomakeCancelJobs<CR>
nnoremap <Leader>njc :NeomakeCancelJob<SPACE>
nnoremap <Leader>nf :Neoformat<CR>
nnoremap nm :Neomake<CR>
nnoremap nc :NeomakeClean<CR>
nnoremap ns :NeomakeSh<SPACE>
nnoremap njl :NeomakeListJobs<CR>
nnoremap nja :NeomakeCancelJobs<CR>
nnoremap njc :NeomakeCancelJob<SPACE>
nnoremap nf :Neoformat<CR>
" For workspace
nnoremap <Leader>sw :ToggleWorkspace<CR>
" Quickfix & Location list mappings
nnoremap <Leader>fn :cnext<CR>
nnoremap <Leader>fp :cprevious<CR>
nnoremap <Leader>fo :copen<CR>
nnoremap <Leader>fc :cclose<CR>
nnoremap <Leader>fs :vimgrep<SPACE>
nnoremap <Leader>ft :call ToggleQuickfixList()<CR>
nnoremap <Leader>ffn :lnext<CR>
nnoremap <Leader>ffp :lprevious<CR>
nnoremap <Leader>ffo :lopen<CR>
nnoremap <Leader>ffc :lclose<CR>
nnoremap <Leader>ffs :lvimgrep<SPACE>
nnoremap <Leader>fft :call ToggleLocationList()<CR>
nnoremap qo :copen<CR>
nnoremap qc :cclose<CR>
nnoremap qs :vimgrep<SPACE>
nnoremap qt :call ToggleQuickfixList()<CR>
nnoremap Lo :lopen<CR>
nnoremap Lc :lclose<CR>
nnoremap Ls :lvimgrep<SPACE>
nnoremap Lt :call ToggleLocationList()<CR>
" Key Bindings to help with terminal mode
:tnoremap jk <C-\><C-n>
@ -362,9 +353,9 @@ command! -bang -nargs=* GGrep
" --------------------------- Autocmd groups ---------------------------------
augroup vimplug_maps
au!
au FileType vim nmap <Leader>pg :PlugUpgrade<CR>
au FileType vim nmap <Leader>pd :PlugUpdate<CR>
au FileType vim nmap <Leader>pc :PlugClean<CR>
au FileType vim nmap pg :PlugUpgrade<CR>
au FileType vim nmap pd :PlugUpdate<CR>
au FileType vim nmap pc :PlugClean<CR>
augroup END
augroup haskell_maps
@ -427,7 +418,7 @@ augroup rust_maps
au FileType rust nmap <buffer> gd <plug>DeopleteRustGoToDefinitionDefault
au FileType rust nmap <buffer> K <plug>DeopleteRustShowDocumentation
au FileType rust nmap <buffer> gv <plug>DeopleteRustGoToDefinitionVSplit
au FileType rust nmap <buffer> gh <plug>DeopleteRustGoToDefinitionSplit
au FileType rust nmap <buffer> g- <plug>DeopleteRustGoToDefinitionSplit
au FileType rust nmap <buffer> gt <plug>DeopleteRustGoToDefinitionTab
augroup END