Fix Tmux and Vim integrated navigation
This commit is contained in:
parent
38a63ae5fc
commit
9658903ed2
16
.tmux.conf
16
.tmux.conf
@ -19,12 +19,18 @@ bind '"' split-window -c "#{pane_current_path}"
|
||||
bind % split-window -h -c "#{pane_current_path}"
|
||||
|
||||
### vim/tmux navigation
|
||||
### https://github.com/christoomey/vim-tmux-navigator
|
||||
set -g focus-events on
|
||||
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
||||
bind -n C-Left if-shell "$is_vim" "send-keys C-h" "select-pane -L"
|
||||
bind -n C-Down if-shell "$is_vim" "send-keys C-j" "select-pane -D"
|
||||
bind -n C-Up if-shell "$is_vim" "send-keys C-k" "select-pane -U"
|
||||
bind -n C-Right if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
||||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(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'
|
||||
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
|
||||
|
||||
# change windows
|
||||
bind -n S-Right next-window
|
||||
|
22
nvim/lua/custom/plugins/vim-tmux-navigator.lua
Normal file
22
nvim/lua/custom/plugins/vim-tmux-navigator.lua
Normal file
@ -0,0 +1,22 @@
|
||||
-- Seamless navigation between tmux and vim windows.
|
||||
-- https://github.com/christoomey/vim-tmux-navigator
|
||||
return {
|
||||
'christoomey/vim-tmux-navigator',
|
||||
cmd = {
|
||||
'TmuxNavigateLeft',
|
||||
'TmuxNavigateDown',
|
||||
'TmuxNavigateUp',
|
||||
'TmuxNavigateRight',
|
||||
'TmuxNavigatePrevious',
|
||||
},
|
||||
keys = {
|
||||
{ '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>' },
|
||||
{ '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' },
|
||||
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' },
|
||||
{ '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' },
|
||||
{ '<c-\\>', '<cmd><C-U>TmuxNavigatePrevious<cr>' },
|
||||
},
|
||||
init = function()
|
||||
vim.g.tmux_navigator_disable_when_zoomed = 1
|
||||
end,
|
||||
}
|
Loading…
Reference in New Issue
Block a user