feat(nav): vim-aware alt+h/j/k/l resize for smart-splits.nvim

This commit is contained in:
root committed 2026-11-02 10:46:20 -05:00
1 parent f748c2e619
commit c57c8f1579
1 file changed
+17 -7
+17 -7
View File
@@ -33,13 +33,14 @@ bind -N "Focus pane right" -n C-M-Right select-pane -R
bind -N "Focus pane up" -n C-M-Up select-pane -U bind -N "Focus pane up" -n C-M-Up select-pane -U
bind -N "Focus pane down" -n C-M-Down select-pane -D bind -N "Focus pane down" -n C-M-Down select-pane -D
# ctrl+h/j/k/l: vim-aware pane navigation, the tmux half of nvim's # ctrl+h/j/k/l: vim-aware pane navigation, the tmux half of smart-splits.nvim
# config.pane_nav. In an nvim/vim/fzf pane the key is forwarded so nvim moves # (nvim's config.pane_nav hands tmux panes to it). In an nvim/vim/fzf pane the
# between its own splits and, at its outer edge, hands off with # key is forwarded so nvim moves between its own splits and, at its outer edge,
# `tmux select-pane -t $TMUX_PANE`; elsewhere tmux moves directly. "Is vim" is # selects the tmux pane itself; elsewhere tmux moves directly. "Is vim" is
# smart-splits' @pane-is-vim pane option or the pane's foreground command, read # smart-splits' @pane-is-vim pane option or the pane's foreground command
# as a format (no ps fork per keypress). Ghostty passes these keys through # (vim without smart-splits, fzf), read as a format (no ps fork per keypress).
# (keybind = clear); prefix + ctrl+l is the clear-screen escape hatch. # Ghostty passes these keys through (keybind = clear); prefix + ctrl+l is the
# clear-screen escape hatch.
bind -N "Focus pane left (vim-aware)" -n C-h if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-h' 'select-pane -L' bind -N "Focus pane left (vim-aware)" -n C-h if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-h' 'select-pane -L'
bind -N "Focus pane down (vim-aware)" -n C-j if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-j' 'select-pane -D' bind -N "Focus pane down (vim-aware)" -n C-j if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-j' 'select-pane -D'
bind -N "Focus pane up (vim-aware)" -n C-k if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-k' 'select-pane -U' bind -N "Focus pane up (vim-aware)" -n C-k if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-k' 'select-pane -U'
@@ -55,6 +56,15 @@ bind -N "Resize pane down" -n C-M-S-Down resize-pane -D 5
bind -N "Resize pane up" -n C-M-S-Up resize-pane -U 5 bind -N "Resize pane up" -n C-M-S-Up resize-pane -U 5
bind -N "Resize pane right" -n C-M-S-Right resize-pane -R 5 bind -N "Resize pane right" -n C-M-S-Right resize-pane -R 5
# alt+h/j/k/l: vim-aware resize, smart-splits' resize keys. An @pane-is-vim
# pane gets the key, so smart-splits resizes its split and, at its outer edge,
# the tmux pane; elsewhere tmux resizes by 3, smart-splits' default amount.
# Only @pane-is-vim forwards: vim/fzf without smart-splits have no resize binds.
bind -N "Resize pane left (vim-aware)" -n M-h if -F '#{@pane-is-vim}' 'send-keys M-h' 'resize-pane -L 3'
bind -N "Resize pane down (vim-aware)" -n M-j if -F '#{@pane-is-vim}' 'send-keys M-j' 'resize-pane -D 3'
bind -N "Resize pane up (vim-aware)" -n M-k if -F '#{@pane-is-vim}' 'send-keys M-k' 'resize-pane -U 3'
bind -N "Resize pane right (vim-aware)" -n M-l if -F '#{@pane-is-vim}' 'send-keys M-l' 'resize-pane -R 3'
# Window navigation # Window navigation
bind -N "Rename window" r command-prompt -I "#W" "rename-window -- '%%'" bind -N "Rename window" r command-prompt -I "#W" "rename-window -- '%%'"
bind -N "Create window" c new-window -c "#{pane_current_path}" bind -N "Create window" c new-window -c "#{pane_current_path}"