fix(nvim): C-h reaches tmux from snacks explorer - #9
Merged
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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
FileTypeautocmd forsnacks_picker_listbuffers that sets a buffer-local<C-h>mapping to directly calltmux 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.
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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>runswincmd h, which lands in that root; snacks then bounces focus back into the editor withwincmd l. Because the window number changed, the navigator concludes it moved within Neovim and never forwards the keystroke totmux 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'ssnacks_picker_listfiletype that talks to tmux directly, bypassing the bouncedwincmd h. The Explorer is pinned leftmost, so "left" is unambiguously the tmux pane beside it. Guarded by$TMUXso 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.