2017-12-21 12:19:25 -06:00
|
|
|
" common typo fixes
|
|
|
|
command! WQ wq
|
|
|
|
command! Wq wq
|
|
|
|
command! Wqa wqa
|
|
|
|
command! W w
|
|
|
|
command! Q q
|
|
|
|
|
|
|
|
" best leader
|
|
|
|
let mapleader = "\<Space>"
|
|
|
|
|
|
|
|
" enter insert mode when entering a terminal buffer
|
2018-07-13 12:08:08 -05:00
|
|
|
augroup InsertModeOnBlankTerminal
|
|
|
|
autocmd BufWinEnter,WinEnter term://* startinsert
|
|
|
|
augroup END
|
2017-12-21 12:19:25 -06:00
|
|
|
|
2020-01-22 17:25:47 -06:00
|
|
|
" terminal mappings
|
|
|
|
nnoremap <leader>t :split term://$SHELL<CR><C-\><C-n>:resize 24<CR>i
|
|
|
|
nnoremap <C-t> :split term://$SHELL<CR><C-\><C-n>:resize 24<CR>i
|
|
|
|
nnoremap <leader><leader>t :vsplit term://$SHELL<CR><C-\><C-n>:vertical resize 120<CR>i
|
|
|
|
" nnoremap <C-S-T> :vsplit term://$SHELL<CR><C-\><C-n>:vertical resize 120<CR>i
|
|
|
|
nnoremap <C-v> :vsplit term://$SHELL<CR><C-\><C-n>:vertical resize 120<CR>i
|
|
|
|
|
|
|
|
" close the terminal
|
|
|
|
tnoremap <C-w> <C-\><C-n>:q!<CR>
|
|
|
|
tnoremap <leader>w <C-\><C-n>:q!<CR>
|
|
|
|
tnoremap <C-n> <C-\><C-n>
|
|
|
|
tnoremap <C-[> <C-\><C-n>
|
|
|
|
|
|
|
|
" moving between terminal splits
|
|
|
|
tnoremap <C-h> <C-\><C-n>:TmuxNavigateLeft<CR>
|
|
|
|
tnoremap <C-j> <C-\><C-n>:TmuxNavigateDown<CR>
|
|
|
|
tnoremap <C-k> <C-\><C-n>:TmuxNavigateUp<CR>
|
|
|
|
tnoremap <C-l> <C-\><C-n>:TmuxNavigateRight<CR>
|
|
|
|
|
2017-12-21 12:19:25 -06:00
|
|
|
" Jump to the next or previous line that has the same level or a lower
|
|
|
|
" level of indentation than the current line.
|
|
|
|
"
|
|
|
|
" exclusive (bool): true: Motion is exclusive
|
|
|
|
" false: Motion is inclusive
|
|
|
|
" fwd (bool): true: Go to next line
|
|
|
|
" false: Go to previous line
|
|
|
|
" lowerlevel (bool): true: Go to line with lower indentation level
|
|
|
|
" false: Go to line with the same indentation level
|
|
|
|
" skipblanks (bool): true: Skip blank lines
|
|
|
|
" false: Don't skip blank lines
|
|
|
|
function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
|
2018-07-13 12:08:08 -05:00
|
|
|
let line = line('.')
|
|
|
|
let column = col('.')
|
|
|
|
let lastline = line('$')
|
|
|
|
let indent = indent(line)
|
|
|
|
let stepvalue = a:fwd ? 1 : -1
|
|
|
|
while (line > 0 && line <= lastline)
|
|
|
|
let line = line + stepvalue
|
2019-02-04 01:43:53 -06:00
|
|
|
if ( a:lowerlevel == 0 && indent(line) == indent ||
|
2019-11-21 11:20:38 -06:00
|
|
|
\ a:lowerlevel == 1 && indent(line) < indent ||
|
2019-02-04 01:43:53 -06:00
|
|
|
\ a:lowerlevel == -1 && indent(line) > indent)
|
2018-07-13 12:08:08 -05:00
|
|
|
if (! a:skipblanks || strlen(getline(line)) > 0)
|
|
|
|
if (a:exclusive)
|
|
|
|
let line = line - stepvalue
|
|
|
|
endif
|
|
|
|
exe line
|
2019-02-04 01:43:53 -06:00
|
|
|
exe 'normal ' (column+1) . '|'
|
2018-07-13 12:08:08 -05:00
|
|
|
return
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endwhile
|
2017-12-21 12:19:25 -06:00
|
|
|
endfunction
|
|
|
|
|
2019-02-04 01:43:53 -06:00
|
|
|
" moving back and forth between lines of same or lower indentation should be sane
|
2017-12-21 12:19:25 -06:00
|
|
|
nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
|
|
|
|
nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
|
|
|
|
nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
|
|
|
|
nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
|
2019-02-04 01:43:53 -06:00
|
|
|
nnoremap <silent> [<C-l> :call NextIndent(0, 0, -1, 1)<CR>
|
|
|
|
nnoremap <silent> ]<C-l> :call NextIndent(0, 1, -1, 1)<CR>
|
2017-12-21 12:19:25 -06:00
|
|
|
vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
|
|
|
|
vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
|
|
|
|
vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
|
|
|
|
vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
|
|
|
|
onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
|
|
|
|
onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
|
|
|
|
onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
|
|
|
|
onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>
|
|
|
|
|
|
|
|
" run make with leader,m
|
|
|
|
nnoremap <leader>m :call RunMake()<CR>
|
|
|
|
|
2019-04-03 12:39:40 -05:00
|
|
|
" NERDTree bindings
|
|
|
|
" show file manager in current directory
|
|
|
|
nnoremap <C-n> :NERDTreeToggle<CR>
|
|
|
|
" show file manager in git repo root
|
|
|
|
nnoremap <leader>n :call NERDProjectViewer()<CR>
|
|
|
|
" focus the current file in NERDTree
|
|
|
|
nnoremap <leader>gn :NERDTreeFind<CR>
|
2017-12-21 12:19:25 -06:00
|
|
|
|
|
|
|
" don't kill vim
|
2019-02-04 01:43:53 -06:00
|
|
|
" REBIND
|
2017-12-21 12:19:25 -06:00
|
|
|
nnoremap <leader>K <Nop>
|
|
|
|
nnoremap <S-K> <NOP>
|
|
|
|
|
|
|
|
" quick paragraph formatting
|
|
|
|
vmap Q gq
|
|
|
|
nmap Q gqap
|
|
|
|
|
|
|
|
" launch fzf for the current git repo
|
|
|
|
nnoremap <C-p> :GitFiles<CR>
|
|
|
|
|
|
|
|
" launch fzf for files in the current directory
|
|
|
|
nnoremap <C-o> :Files<CR>
|
|
|
|
|
|
|
|
" launch fzf for files modified or not in git
|
|
|
|
nnoremap <C-u> :GFiles?<CR>
|
|
|
|
|
|
|
|
" launch fzf for open buffers (files)
|
|
|
|
nnoremap <C-b> :Buffers<CR>
|
|
|
|
|
|
|
|
" launch fzf for open buffers (files)
|
|
|
|
nnoremap <leader>l :Buffers<CR>
|
|
|
|
|
|
|
|
" switch to previous buffer
|
|
|
|
nnoremap <leader>h :b#<CR>
|
|
|
|
|
|
|
|
" use leader j and k to switch buffers as well
|
|
|
|
nnoremap <leader>k :bnext<CR>
|
|
|
|
nnoremap <leader>j :bprevious<CR>
|
2020-01-22 17:25:47 -06:00
|
|
|
|
|
|
|
" window/pane navigation
|
|
|
|
nnoremap <C-h> :TmuxNavigateLeft<CR>
|
|
|
|
nnoremap <C-j> :TmuxNavigateDown<CR>
|
|
|
|
nnoremap <C-k> :TmuxNavigateUp<CR>
|
|
|
|
nnoremap <C-l> :TmuxNavigateRight<CR>
|
2017-12-21 12:19:25 -06:00
|
|
|
|
2020-01-20 11:40:26 -06:00
|
|
|
if has('nvim')
|
|
|
|
nnoremap <leader>r :source $vimdir/init.vim<CR>
|
|
|
|
else
|
|
|
|
nnoremap <leader>r :source $HOME/.vimrc<CR>
|
|
|
|
endif
|
2019-03-28 17:00:56 -05:00
|
|
|
|
2019-02-04 01:43:53 -06:00
|
|
|
" change buffers with leader,tab
|
|
|
|
nnoremap <leader><Tab> :bnext<CR>
|
|
|
|
nnoremap <leader><S-Tab> :bprevious<CR>
|
|
|
|
|
2017-12-21 12:19:25 -06:00
|
|
|
" fast word change
|
|
|
|
nnoremap <leader>c ciw
|
|
|
|
nnoremap <leader>C ciW
|
|
|
|
|
2019-04-03 12:39:40 -05:00
|
|
|
" fast splits
|
|
|
|
nnoremap <silent> <leader>s :split<CR>
|
|
|
|
nnoremap <silent> <leader>v :vsplit<CR>
|
|
|
|
|
|
|
|
" fast split closing
|
2019-04-03 12:43:04 -05:00
|
|
|
nnoremap <silent> <leader>q <C-w>q
|
2019-04-03 12:39:40 -05:00
|
|
|
|
2017-12-21 12:19:25 -06:00
|
|
|
" clear search higlight
|
2019-04-03 12:39:40 -05:00
|
|
|
nnoremap <silent> <leader>/ :let @/ = ""<CR>:<BACKSPACE>
|
2017-12-21 12:19:25 -06:00
|
|
|
|
|
|
|
" remap jk/jj and its variants to escape
|
|
|
|
inoremap jj <Esc>
|
|
|
|
inoremap Jj <Esc>
|
|
|
|
inoremap Jj <Esc>
|
|
|
|
inoremap JJ <Esc>
|
|
|
|
inoremap jk <Esc>
|
|
|
|
inoremap Jk <Esc>
|
|
|
|
inoremap jK <Esc>
|
|
|
|
inoremap JK <Esc>
|
|
|
|
|
|
|
|
" use hjkl-movement between rows when soft wrapping:
|
|
|
|
nnoremap j gj
|
|
|
|
nnoremap k gk
|
|
|
|
vnoremap j gj
|
|
|
|
vnoremap k gk
|
|
|
|
|
2019-02-04 01:43:53 -06:00
|
|
|
" camel case motions
|
2017-12-21 12:19:25 -06:00
|
|
|
map <silent> ,w <Plug>CamelCaseMotion_w
|
|
|
|
map <silent> ,b <Plug>CamelCaseMotion_b
|
|
|
|
map <silent> ,e <Plug>CamelCaseMotion_e
|
|
|
|
map <silent> ,ge <Plug>CamelCaseMotion_ge
|
|
|
|
|
|
|
|
" inner _ objects
|
|
|
|
omap <silent> ib <Plug>CamelCaseMotion_ib
|
|
|
|
xmap <silent> ib <Plug>CamelCaseMotion_ib
|
|
|
|
omap <silent> ie <Plug>CamelCaseMotion_ie
|
|
|
|
xmap <silent> ie <Plug>CamelCaseMotion_ie
|
|
|
|
|
|
|
|
" remove trailing whitespace
|
|
|
|
map <F3> mw:%s/\s\+$//<CR>:let @/ = ""<CR>'w
|
|
|
|
|
|
|
|
" close buffer with leader-w
|
|
|
|
nnoremap <silent> <leader>w :bd<CR>
|
|
|
|
|
|
|
|
" toggle spell checking:
|
2019-02-04 01:43:53 -06:00
|
|
|
map <F4> :setlocal spell!<CR>
|
2017-12-21 12:19:25 -06:00
|
|
|
|
|
|
|
" open urls, files, etc. example: http://google.com:
|
|
|
|
noremap <leader>o :!xdg-open <cfile><CR><CR>
|
|
|
|
|
|
|
|
" insert newline
|
2019-02-04 01:43:53 -06:00
|
|
|
" NOTE: doesn't work in terminals?
|
2017-12-21 12:19:25 -06:00
|
|
|
" noremap <S-Enter> i<Enter><Esc>
|
|
|
|
" noremap <C-o> i<Enter><Esc>
|
|
|
|
|
2019-02-04 01:43:53 -06:00
|
|
|
" prevent wildmenu
|
2017-12-21 12:19:25 -06:00
|
|
|
map q: :q
|
|
|
|
noremap qqq: q:
|
|
|
|
|
|
|
|
" sane n/N behavior
|
|
|
|
nnoremap <expr> n 'Nn'[v:searchforward]
|
|
|
|
nnoremap <expr> N 'nN'[v:searchforward]
|
|
|
|
|
|
|
|
" better command history navigation
|
|
|
|
cnoremap <c-n> <down>
|
|
|
|
cnoremap <c-p> <up>
|
|
|
|
|
|
|
|
" keep selection after indenting visual selection
|
|
|
|
xnoremap < <gv
|
|
|
|
xnoremap > >gv
|
|
|
|
|
2019-02-04 01:43:53 -06:00
|
|
|
" distraction-free mode
|
2019-09-26 12:04:23 -05:00
|
|
|
nnoremap <silent> <leader>df :DistractionFreeMode<CR>
|
2019-02-04 01:43:53 -06:00
|
|
|
|
|
|
|
" recalc syntax highlighting
|
|
|
|
nnoremap <leader>gs :syntax sync fromstart<CR>
|
2019-09-26 12:04:23 -05:00
|
|
|
|
|
|
|
" lsp bindings
|
|
|
|
|
|
|
|
" coc
|
|
|
|
|
|
|
|
" open coc config
|
|
|
|
nnoremap <leader><space>c :CocConfig<CR>
|
|
|
|
|
2020-01-22 08:34:12 -06:00
|
|
|
" smart jumps
|
2019-11-21 11:20:38 -06:00
|
|
|
nmap <silent> gd <Plug>(coc-definition)
|
|
|
|
nmap <silent> gy <Plug>(coc-type-definition)
|
|
|
|
nmap <silent> gi <Plug>(coc-implementation)
|
|
|
|
nmap <silent> gr <Plug>(coc-references)
|
|
|
|
|
2020-01-22 08:34:12 -06:00
|
|
|
nmap <silent> g[ <Plug>(coc-diagnostic-prev)
|
|
|
|
nmap <silent> g] <Plug>(coc-diagnostic-next)
|
|
|
|
|
2019-11-21 11:20:38 -06:00
|
|
|
nmap <leader>ac <Plug>(coc-codeaction)
|
|
|
|
nmap <leader>qf <Plug>(coc-fix-current)
|
|
|
|
|
2019-09-26 12:04:23 -05:00
|
|
|
" ale
|
|
|
|
|
|
|
|
" go to definitions
|
|
|
|
" nnoremap <leader>gd :ALEGoToDefinition<CR>
|
|
|
|
" nnoremap <leader>gh :ALEGoToDefinitionInSplit<CR>
|
|
|
|
" nnoremap <leader>gv :ALEGoToDefinitionInVSplit<CR>
|
|
|
|
|