From f9cec048c49c13d7fc35f422d2b1151f0d75d2cb Mon Sep 17 00:00:00 2001 From: Jarod Taylor Date: Mon, 8 Jun 2026 20:51:14 -0500 Subject: [PATCH 1/2] fix(nvim): C-h reaches tmux from snacks explorer In the snacks Explorer, 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 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. ( skip the root, so they already worked.) Add a buffer-local 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. --- home/dot_config/nvim/lua/plugins/editor.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/home/dot_config/nvim/lua/plugins/editor.lua b/home/dot_config/nvim/lua/plugins/editor.lua index dd58978..abfd5b0 100644 --- a/home/dot_config/nvim/lua/plugins/editor.lua +++ b/home/dot_config/nvim/lua/plugins/editor.lua @@ -1,3 +1,23 @@ +-- Inside the snacks.nvim Explorer, can't reach the left tmux pane the way +-- it does from a normal buffer. The Explorer is a split-layout picker with a +-- hidden "root" window: vim-tmux-navigator's runs `wincmd h`, which lands +-- in that root, and snacks immediately bounces focus back into the editor with +-- `wincmd l`. The window number changed, so vim-tmux-navigator concludes it +-- moved within Neovim and never forwards the keystroke to tmux. ( don't +-- pass through the root, so they already work.) Fix: in the Explorer only, send +-- straight to tmux, bypassing the `wincmd h` that gets bounced. The +-- Explorer is pinned leftmost, so "left" is unambiguously the tmux pane beside it. +vim.api.nvim_create_autocmd("FileType", { + pattern = "snacks_picker_list", + callback = function(ev) + if vim.env.TMUX then + vim.keymap.set("n", "", function() + vim.fn.system("tmux select-pane -L") + end, { buffer = ev.buf, desc = "Tmux navigate left (snacks explorer)" }) + end + end, +}) + return { -- Seamless C-h/j/k/l navigation across Neovim splits AND tmux panes. -- The tmux half lives in ~/.config/tmux/tmux.conf (inline bind-key lines). From 0bbff30e02280ef0fcf46450e3cf47a745cc5189 Mon Sep 17 00:00:00 2001 From: Jarod Taylor Date: Mon, 8 Jun 2026 21:12:49 -0500 Subject: [PATCH 2/2] fix(nvim): wrap explorer nav autocmd in a named augroup 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 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). --- home/dot_config/nvim/lua/plugins/editor.lua | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/home/dot_config/nvim/lua/plugins/editor.lua b/home/dot_config/nvim/lua/plugins/editor.lua index abfd5b0..9892a99 100644 --- a/home/dot_config/nvim/lua/plugins/editor.lua +++ b/home/dot_config/nvim/lua/plugins/editor.lua @@ -1,19 +1,24 @@ --- Inside the snacks.nvim Explorer, can't reach the left tmux pane the way --- it does from a normal buffer. The Explorer is a split-layout picker with a --- hidden "root" window: vim-tmux-navigator's runs `wincmd h`, which lands --- in that root, and snacks immediately bounces focus back into the editor with --- `wincmd l`. The window number changed, so vim-tmux-navigator concludes it --- moved within Neovim and never forwards the keystroke to tmux. ( don't --- pass through the root, so they already work.) Fix: in the Explorer only, send --- straight to tmux, bypassing the `wincmd h` that gets bounced. The --- Explorer is pinned leftmost, so "left" is unambiguously the tmux pane beside it. +-- from the snacks.nvim Explorer can't reach the left tmux pane the way it +-- does from a normal buffer. The Explorer is a split-layout picker with a hidden +-- "root" window: vim-tmux-navigator's runs `wincmd h`, lands in that root, +-- and snacks bounces focus back into the editor with `wincmd l`. The window +-- number changed, so the navigator concludes it moved within Neovim and never +-- forwards to tmux. ( don't pass through the root, so they already work.) +-- +-- Fix: rebind on the picker list buffer to go straight to the left tmux +-- pane, bypassing the bounced `wincmd h`. This attaches to every picker's list +-- window, not just the Explorer — but that's harmless: from any list-window left +-- edge the normal navigator would forward to tmux anyway, so the result matches. +-- The augroup's clear=true keeps a re-source (`:Lazy reload`) from stacking +-- duplicate autocmds (and thus duplicate buffer-local maps). vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("snacks_picker_tmux_nav", { clear = true }), pattern = "snacks_picker_list", callback = function(ev) if vim.env.TMUX then vim.keymap.set("n", "", function() vim.fn.system("tmux select-pane -L") - end, { buffer = ev.buf, desc = "Tmux navigate left (snacks explorer)" }) + end, { buffer = ev.buf, desc = "Tmux navigate left (snacks picker list)" }) end end, })