chore(vim): add TMUX plugins

This commit is contained in:
Stefan Imhoff
2021-12-11 16:04:16 +01:00
parent 6317ae09ea
commit da2ed8be42
4 changed files with 39 additions and 0 deletions

View File

@@ -28,4 +28,5 @@ source ~/.config/nvim/plugins/treesitter.lua
source ~/.config/nvim/plugins/trouble.lua
source ~/.config/nvim/plugins/ultisnips.vim
source ~/.config/nvim/plugins/vim-easymotion.vim
source ~/.config/nvim/plugins/vimux.vim
source ~/.config/nvim/plugins/web-devicons.lua

View File

@@ -77,6 +77,11 @@ Plug 'hoob3rt/lualine.nvim'
Plug 'akinsho/bufferline.nvim'
Plug 'kyazdani42/nvim-web-devicons'
" TMUX
Plug 'christoomey/vim-tmux-navigator'
Plug 'preservim/vimux'
Plug 'tyewang/vimux-jest-test'
" Tpope
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-commentary'

14
nvim/plugins/vimux.vim Normal file
View File

@@ -0,0 +1,14 @@
" Vimux
" https://github.com/preservim/vimux
let g:VimuxHeight = "30"
let g:VimuxOrientation = 'h'
let g:VimuxUseNearestPane = 0
" Mappings
nmap <leader>vt :VimuxTogglePane<CR>
nmap <leader>vp :VimuxPromptCommand<CR>
nmap <leader>vl :VimuxRunLastCommand<CR>
nmap <leader>vj :RunJest<CR>
nmap <leader>vjb :RunJestOnBuffer<CR>
nmap <leader>vjf :RunJestFocused<CR>

View File

@@ -71,6 +71,25 @@ bind-key -T copy-mode-vi Enter send-keys -X copy-selection
bind p run "tmux paste-buffer"
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
set -g @shell_mode 'vi'
# List of plugins (prefix + I to install, prefix + U to update)