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:
parent
587aeef5d7
commit
c284486540
@ -1,7 +1,7 @@
|
||||
augroup benieAugroup
|
||||
autocmd!
|
||||
|
||||
if $TMUX !=# ''
|
||||
if tmux#inSession()
|
||||
" [Un]set tmux window option to detect when to change pane.
|
||||
call tmux#setNavigationFlag()
|
||||
au FocusGained * silent call tmux#setNavigationFlag()
|
||||
@ -28,4 +28,20 @@ augroup benieAugroup
|
||||
|
||||
" Augment vim-signify by modifying it's autocmds
|
||||
au User SignifyAutocmds call do#signify()
|
||||
|
||||
if has('nvim')
|
||||
" Start in terminal-insert mode.
|
||||
autocmd TermOpen term://* startinsert
|
||||
" Don't show the line number column in terminal-insert mode.
|
||||
autocmd TermEnter term://* set nonumber | set norelativenumber
|
||||
" But do show the line number column in terminal-normal mode.
|
||||
autocmd TermLeave term://* set number | set relativenumber
|
||||
" Automatically press enter when the terminal process exits.
|
||||
autocmd TermClose term://*
|
||||
\ if (expand('<afile>') !~ "fzf") &&
|
||||
\ (expand('<afile>') !~ "ranger") &&
|
||||
\ (expand('<afile>') !~ "coc") |
|
||||
\ call nvim_input('<CR>') |
|
||||
\ endif
|
||||
endif
|
||||
augroup END
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user