Skip to content

fix(nvim): C-h reaches tmux from snacks explorer - #9

Merged
jarodtaylor merged 2 commits into
mainfrom
fix/snacks-explorer-tmux-nav
Jun 9, 2026
Merged

jarodtaylor merged 2 commits into
mainfrom
fix/snacks-explorer-tmux-nav

Conversation

@jarodtaylor

Copy link
Copy Markdown
Owner

What

In the snacks Explorer, <C-h> wrapped to the editor buffer instead of moving to the left tmux pane. <C-l/j/k> worked fine.

Why

The Explorer is a split-layout picker with a hidden root window. vim-tmux-navigator's <C-h> runs wincmd h, which lands in that root; snacks then bounces focus back into the editor with wincmd l. Because the window number changed, the navigator concludes it moved within Neovim and never forwards the keystroke to tmux select-pane -L. <C-l/j/k> don't pass through the root, so they were unaffected.

Fix

A buffer-local <C-h> on the explorer's snacks_picker_list filetype that talks to tmux directly, bypassing the bounced wincmd h. The Explorer is pinned leftmost, so "left" is unambiguously the tmux pane beside it. Guarded by $TMUX so it's a no-op when Neovim runs outside tmux. The global navigator keymaps are untouched.

Verified

Restarted nvim → opened Explorer → <C-h> now moves to the left tmux pane; <C-l> still moves right into the editor. Confirmed live on the M5.

In the snacks Explorer, <C-h> wrapped to the editor buffer instead of
moving to the left tmux pane. The Explorer is a split-layout picker with
a hidden root window; vim-tmux-navigator's <C-h> runs `wincmd h`, lands
in that root, and snacks bounces focus back into the editor with
`wincmd l`. The window changed, so the navigator assumes it moved within
Neovim and never forwards to tmux. (<C-l/j/k> skip the root, so they
already worked.)

Add a buffer-local <C-h> on the explorer's `snacks_picker_list` filetype
that talks to tmux directly, bypassing the bounced `wincmd h`. The
Explorer is pinned leftmost, so "left" is unambiguously the tmux pane
beside it. Guarded by $TMUX so it's a no-op outside tmux.
Copilot AI review requested due to automatic review settings June 9, 2026 01:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a navigation issue where <C-h> in the snacks.nvim Explorer didn't reach the left tmux pane due to vim-tmux-navigator being confused by a hidden "root" window in the Explorer's split layout. The fix adds a buffer-local keymap that directly invokes tmux select-pane -L, bypassing the problematic wincmd h bounce.

Changes:

  • Added a FileType autocmd for snacks_picker_list buffers that sets a buffer-local <C-h> mapping to directly call tmux select-pane -L, guarded by $TMUX
  • Included a detailed comment block explaining the root cause and rationale for the workaround

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread home/dot_config/nvim/lua/plugins/editor.lua
Comment thread home/dot_config/nvim/lua/plugins/editor.lua
Address Copilot review on #9: the FileType autocmd had no group, so a
re-source (`:Lazy reload`, plugin dev) would register duplicate autocmds
and stack duplicate buffer-local <C-h> maps. Wrap it in a named augroup
with clear=true so re-sourcing replaces rather than accumulates.

Keymap behavior is unchanged. Also clarifies in-comment that the binding
intentionally attaches to every picker list buffer (harmless: from any
list-window left edge the navigator forwards to tmux anyway).
@jarodtaylor
jarodtaylor merged commit 1940ab3 into main Jun 9, 2026
5 checks passed
@jarodtaylor
jarodtaylor deleted the fix/snacks-explorer-tmux-nav branch June 9, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants