Make nvim :terminal more consistent with vim

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.
This commit is contained in:
2021-02-18 00:34:50 +00:00
parent 587aeef5d7
commit c284486540
3 changed files with 43 additions and 9 deletions

View File

@@ -5,6 +5,11 @@ 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>
@@ -59,14 +64,26 @@ nnoremap k gk
" Quick write
nnoremap <leader>w :w!<CR>
" Switch panes
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Redraw window
nnoremap <C-w>l <C-l>
" 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>