dotfiles/nvim/.config/nvim/keymappings.vim
Sanchayan Maity 467a660409 nvim: Drop neomake, QFGrep and vim-grepper
Profiling with below
nvim -c 'profile start vim.log' -c 'profile func *' -c 'q'

shows that neomake adds to the start up time. Currently we only use it
for two tasks. Running hlint for Haskell and stack build asynchronously.

Use asyncdo and define a generic wrapper command for running makeprg
asynchronously. This can be used for anything as long as makeprg is
set correctly.

vim-grepper also adds somewhat to the startup time though not much. We
do not need the functionality of switching between grep tools. Here
again just use asyncdo and define a generic command for running grepprg
asynchronously.

Drop QFGrep as we can use in built Cfilter plugin for filtering the
quickfix list.

Note that all start times mentioned above are a few milliseconds not
even more than 5ms. However, we would like to be as fast as possible
and use in built functions.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-05-21 16:39:06 +05:30

172 lines
5.5 KiB
VimL

" Allow saving of files as sudo when I forgot to start vim using sudo
cmap w!! w !sudo tee > /dev/null %
" Remap escape keys to something usable on home row
inoremap jk <Esc>
cnoremap jk <C-C>
inoremap <Esc> <Nop>
cnoremap <Esc> <Nop>
" Use Q to execute default register.
nnoremap Q <Nop>
" Jump and change list
nnoremap <Leader>o :call GotoJump()<CR>
nnoremap <Leader>; :changes<CR>:keepjumps norm g;<Left><Left>
nnoremap <Leader>, :changes<CR>:keepjumps norm g,<Left><Left>
" Async Make mappings
nnoremap <LocalLeader>b :Make<CR>
nnoremap <LocalLeader>B :LMake<CR>
" For Fuzzy
nnoremap <Leader>b :Buffers<CR>
nnoremap <Leader>/ :GFiles?<CR>
nnoremap <Leader>ff :GFiles<CR>
nnoremap <Leader>fF :Files<CR>
nnoremap <Leader>fL :Lines<CR>
nnoremap <Leader>fl :BLines<CR>
nnoremap <Leader>ft :BTags<CR>
nnoremap <Leader>fT :Tags<CR>
nnoremap <Leader>fc :BCommits<CR>
nnoremap <Leader>fC :Commits<CR>
nnoremap <Leader>fh :History:<CR>
nnoremap <Leader>fH :History/<CR>
nnoremap <Leader>fm :Commands<CR>
nnoremap <Leader>fo :Locate<SPACE>
nnoremap <Leader>fk :Maps<CR>
nnoremap <Leader>f/ :Rg<CR>
nnoremap <Leader>fs :exe ':Rg ' . expand('<cword>')<CR>
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)
imap <C-x><C-l> <Plug>(fzf-complete-line)
" Save
nnoremap <Leader>w <Esc>:w<CR>
" Search and Replace
nnoremap sr :%s//g<Left><Left>
nnoremap <Leader>sr :%s/\<<C-r><C-w>\>//g<Left><Left>
" Quit
nnoremap <Leader>x <Esc>:x<CR>
nnoremap <Leader>q <Esc>:q<CR>
nnoremap <Leader>Q <Esc>:qa<CR>
" Navigate buffers
nnoremap [b :bprevious<CR>
nnoremap ]b :bnext<CR>
nnoremap [B :bfirst<CR>
nnoremap ]B :blast<CR>
nnoremap [t :tabprevious<CR>
nnoremap ]t :tabnext<CR>
nnoremap [T :tabfirst<CR>
nnoremap ]T :tablast<CR>
" For floating terminal
nnoremap se :FloatermNew<CR>
nnoremap [s :FloatermPrev<CR>
nnoremap ]s :FloatermNext<CR>
nnoremap st :FloatermToggle<CR>
" For git
nnoremap <Leader>gm :GitMessenger<CR>
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>
" For gitgutter
nnoremap ]h :GitGutterNextHunk<CR>
nnoremap [h :GitGutterPrevHunk<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)
" For workspace
nnoremap <Leader>ws :ToggleWorkspace<CR>
" Quickfix & Location list mappings
nnoremap qo :copen<CR>
nnoremap qc :cclose<CR>
nnoremap [q :cprevious<CR>
nnoremap ]q :cnext<CR>
nnoremap [Q :cfirst<CR>
nnoremap ]Q :clast<CR>
nnoremap qs :Grep<SPACE>
nnoremap q* :Grep <cword><CR>
nnoremap qt :call ToggleQuickfixList()<CR>
nnoremap Lo :lopen<CR>
nnoremap Lc :lclose<CR>
nnoremap [l :lprevious<CR>
nnoremap ]l :lnext<CR>
nnoremap [L :lfirst<CR>
nnoremap ]L :llast<CR>
nnoremap Ls :LGrep<SPACE>
nnoremap L* :LGrep <cword><CR>
nnoremap Lt :call ToggleLocationList()<CR>
" Preview tags
nnoremap pt :ptag <C-R><C-W><CR>
nnoremap [p :ptprevious<CR>
nnoremap ]p :ptnext<CR>
nnoremap po :ppop<CR>
nnoremap pc :pc<CR>
nnoremap pi :psearch <C-R><C-W><CR>
" Short cuts for setting fold methods
nnoremap zmi :set foldmethod=indent<CR>
nnoremap zmm :set foldmethod=manual<CR>
nnoremap zme :set foldmethod=expr<CR>
nnoremap zmk :set foldmethod=marker<CR>
nnoremap zms :set foldmethod=syntax<CR>
" Key Bindings to help with terminal mode
:tnoremap jk <C-\><C-n>
" Key bindings to move between window splits
for key in range(0, 9)
execute 'nnoremap <Space>'.key key.'<C-w>w'
endfor
" Disable Arrow Keys
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" Whick key
nnoremap <silent> <Leader> :<C-U>WhichKey '<Space>'<CR>
nnoremap <silent> <LocalLeader> :<C-U>WhichKey ','<CR>
" Tag helpers
nnoremap <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
nnoremap <A-]> :sp <CR>:exec("tag ".expand("<cword>"))<CR>
" Move across wrapped lines like regular lines
" Go to the first non-blank character of a line
noremap 0 ^
" Just in case you need to go to the very beginning of a line
noremap ^ 0
" Make dot work on visually selected lines
vnoremap . :norm.<CR>
" Go to the last file we changed
nnoremap <BS> <C-^>
" Map to ; to : for easy access to command mode. Behaviour of ; can be taken
" care of by f due to clever-f
nnoremap ; :
" Asynchronous make
command! -bang -nargs=* -complete=file Make call asyncdo#run(<bang>0, &makeprg, <f-args>)
command! -bang -nargs=* -complete=file LMake call asyncdo#lrun(<bang>0, &makeprg, <f-args>)