Vim's :terminal feels much more ergonomic, adding various mappings to make the experience more similar, mainly by adding a few `<C-w>` mappings for the most common actions. Additionally, disable vim-tmux-navigators default mappings and setup both normal and terminal mode mappings for `<C-w>{h,j,k,l}` in addition to the normal mode mappings for `<C-{h,j,j,l}>` to make the pane switching experience more consistent across all buffer types.
128 lines
3.4 KiB
VimL
128 lines
3.4 KiB
VimL
" coc.nvim
|
|
nmap <leader>fi <Plug>(coc-fix-current)
|
|
nmap <leader>gd <Plug>(coc-definition)
|
|
nmap <leader>gt <Plug>(coc-type-definition)
|
|
nmap <leader>sd <Plug>(coc-diagnostic-info)
|
|
nmap <leader>gr <Plug>(coc-references)
|
|
|
|
if has('nvim')
|
|
" Make nvim :terminal more like vim :terminal
|
|
tnoremap <C-w>N <C-\><C-n>
|
|
endif
|
|
|
|
" termdebug
|
|
" TODO: Detecet if termdebug is loaded, if not do the default action.
|
|
nnoremap <C-W><C-G> :Gdb<CR>
|
|
nnoremap <C-W><C-E> :Program<CR>
|
|
nnoremap <C-W><C-S> :Source<CR>
|
|
tnoremap <C-G> :Gdb<CR>
|
|
tnoremap <C-E> :Program<CR>
|
|
tnoremap <C-S> :Source<CR>
|
|
|
|
" GitGutter
|
|
nnoremap <leader>gn :GitGutterNextHunk<CR>
|
|
nnoremap <leader>gp :GitGutterPrevHunk<CR>
|
|
|
|
" Quickfix list
|
|
nnoremap <leader>qo :copen<CR>
|
|
nnoremap <leader>qc :cclose<CR>
|
|
nnoremap <leader>qq :cc<CR>
|
|
nnoremap <leader>qn :cnext<CR>
|
|
nnoremap <leader>qp :cprevious<CR>
|
|
nnoremap <leader>qf :cfirst<CR>
|
|
nnoremap <leader>qa :clast<CR>
|
|
|
|
" Location list
|
|
nnoremap <leader>lo :lopen<CR>
|
|
nnoremap <leader>lc :lclose<CR>
|
|
nnoremap <leader>ll :ll<CR>
|
|
nnoremap <leader>ln :lnext<CR>
|
|
nnoremap <leader>lp :lprevious<CR>
|
|
nnoremap <leader>lf :lfirst<CR>
|
|
nnoremap <leader>la :llast<CR>
|
|
|
|
" Preview window
|
|
nnoremap <leader>pc :pclose<CR>
|
|
nnoremap <leader>pe :pedit<Space>
|
|
nnoremap <leader>ps :psearch<Space>
|
|
|
|
" fzf
|
|
nnoremap <C-f>f :Files<Space>
|
|
nnoremap <C-f>a :Ag<Space>
|
|
nnoremap <C-f>g :GitFiles<CR>
|
|
nnoremap <C-f>b :Buffers<CR>
|
|
nnoremap <C-f>l :BLines<CR>
|
|
nnoremap <C-f>c :Colors<CR>
|
|
nnoremap <C-f>h :Helptags<CR>
|
|
nnoremap <C-f>s :Snippets<CR>
|
|
" Search to the word under the cursor
|
|
nnoremap <leader>ag :Ag <C-R>=expand('<cword>')<CR><CR>
|
|
|
|
" Treat long lines as line containing breaks
|
|
nnoremap j gj
|
|
nnoremap k gk
|
|
" Quick write
|
|
nnoremap <leader>w :w!<CR>
|
|
|
|
" Switch panes in a tmux aware way
|
|
nnoremap <silent> <C-h> :TmuxNavigateLeft<CR>
|
|
nnoremap <silent> <C-j> :TmuxNavigateDown<CR>
|
|
nnoremap <silent> <C-k> :TmuxNavigateUp<CR>
|
|
nnoremap <silent> <C-l> :TmuxNavigateRight<CR>
|
|
nnoremap <silent> <C-w>h :TmuxNavigateLeft<CR>
|
|
nnoremap <silent> <C-w>j :TmuxNavigateDown<CR>
|
|
nnoremap <silent> <C-w>k :TmuxNavigateUp<CR>
|
|
nnoremap <silent> <C-w>l :TmuxNavigateRight<CR>
|
|
if has('nvim')
|
|
tnoremap <silent> <C-w>h <C-\><C-n>:TmuxNavigateLeft<CR>
|
|
tnoremap <silent> <C-w>j <C-\><C-n>:TmuxNavigateDown<CR>
|
|
tnoremap <silent> <C-w>k <C-\><C-n>:TmuxNavigateUp<CR>
|
|
tnoremap <silent> <C-w>l <C-\><C-n>:TmuxNavigateRight<CR>
|
|
else
|
|
tnoremap <silent> h :TmuxNavigateLeft<CR>
|
|
tnoremap <silent> j :TmuxNavigateDown<CR>
|
|
tnoremap <silent> k :TmuxNavigateUp<CR>
|
|
tnoremap <silent> l :TmuxNavigateRight<CR>
|
|
endif
|
|
|
|
" Quick tabs
|
|
nnoremap <leader>tn :tabnew<Space>
|
|
nnoremap <leader>tc :tabclose<CR>
|
|
nnoremap <leader>to :tabonly<CR>
|
|
nnoremap <leader>tm :tabmove<Space>
|
|
|
|
" Clear search highlights
|
|
nnoremap <leader><Space> :nohlsearch<CR>
|
|
|
|
if exists('loaded_oscyank')
|
|
noremap <leader>y :Oscyank<CR>
|
|
else
|
|
" System clipboard yank/put
|
|
noremap <leader>y "+y
|
|
noremap <leader>Y "+Y
|
|
noremap <leader>p "+p
|
|
noremap <leader>P "+P
|
|
endif
|
|
|
|
" Quickly access spelling menu
|
|
inoremap <C-s> <C-g>u<C-X>s
|
|
nnoremap <C-s> i<C-g>u<C-X>s
|
|
|
|
" Disable 'Q' from opening Ex mode
|
|
nnoremap Q <nop>
|
|
" Disable 'K' from loading man pages
|
|
noremap K <nop>
|
|
|
|
" Split line at the cursor
|
|
nnoremap [j i<CR><Esc>
|
|
nnoremap ]j a<CR><Esc>
|
|
|
|
" Toggle Checkbox
|
|
nnoremap <leader><CR> :ToggleCheckbox<CR>
|
|
|
|
" Show highlight groups under the cursor
|
|
nnoremap <leader>hi :CursorHighlightGroups<CR>
|
|
|
|
" Rename C/C++ include guard
|
|
nnoremap <leader>rg :call do#rename_include_guard(expand('<cword>'))<cr>
|