diff --git a/README.md b/README.md index 9ac1c22..0c65ba7 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ scripts/ mermaid-validator.mjs (node process used by config/mermai **Search**: `fff.nvim` handles files and grep (frecency, respects `.gitignore` and `.ignore`). snacks.picker handles everything else. `config/ignore_patterns.lua` holds the shared ignore list used by neo-tree and the snacks pickers. -**Pane navigation** (`config/pane_nav.lua`): `` moves between Neovim splits first. At the outermost split, the move goes to herdr, tmux, or kitty, whichever is the nearest ancestor process. Resize is plain `:resize` on ``; smart-splits is disabled. +**Pane navigation** (`config/pane_nav.lua`): `` moves between Neovim splits first. At the outermost split, the move goes to herdr, tmux, or kitty, whichever is the nearest ancestor process. Under tmux the move goes through smart-splits.nvim, loaded at startup, which flags the pane `@pane-is-vim` for `tmux.conf`. There, `` and `` are smart-splits resize and cross into tmux panes at the edge. Elsewhere smart-splits stays unloaded and resize is plain `:resize` on ``. **Mermaid** (`config/mermaid.lua`): tree-sitter highlights ```` ```mermaid ```` fences in markdown/MDX and `.mmd` files. Diagnostics come from mermaid's own parser running in a node process, which exits after 5 idle minutes. Run `:MermaidCheck` to re-validate. @@ -82,7 +82,6 @@ Core or community plugins turned off in `plugins/user.lua` because something els | Plugin | Replaced by | | --- | --- | | `none-ls.nvim`, `mason-null-ls.nvim` | conform (`mason-null-ls` would auto-register every Mason tool as a second formatter/linter client) | -| `smart-splits.nvim` | `config/pane_nav.lua` + native `:resize` | | `toggleterm.nvim` | kitty / snacks terminals | | `lsp_signature.nvim` (not imported) | astrolsp's built-in signature help (`features.signature_help = true`) | | `refactoring.nvim`, `dev-tools.nvim` (not imported) | LSP code actions (`a`) | diff --git a/lua/config/pane_nav.lua b/lua/config/pane_nav.lua index 4af482d..3dbae04 100644 --- a/lua/config/pane_nav.lua +++ b/lua/config/pane_nav.lua @@ -141,6 +141,11 @@ end --- @param dir "left"|"down"|"up"|"right" function M.navigate(dir) local from = vim.api.nvim_get_current_win() + -- Under tmux smart-splits owns the edge handoff (plugins/user.lua). + if M.env() == "tmux" and vim.api.nvim_win_get_config(from).relative == "" then + require("smart-splits")["move_cursor_" .. dir]() + return + end vim.cmd.wincmd(directions[dir].wincmd) if vim.api.nvim_get_current_win() ~= from then return end if vim.api.nvim_win_get_config(0).relative ~= "" then return end diff --git a/lua/plugins/pane-nav.lua b/lua/plugins/pane-nav.lua index 6562b87..355b249 100644 --- a/lua/plugins/pane-nav.lua +++ b/lua/plugins/pane-nav.lua @@ -1,10 +1,11 @@ --- pane navigation that follows whatever multiplexer Neovim is --- running under (herdr, tmux, or bare kitty) — see config.pane_nav. --- ---- This replaces AstroNvim's smart-splits mappings (which only know ---- tmux/wezterm/kitty and would move the wrong layer inside herdr). The plugin ---- is disabled in plugins/user.lua; its resize binds ---- are plain :resize here. +--- These entries overwrite AstroNvim's smart-splits mappings, which only know +--- tmux/wezterm/kitty and would move the wrong layer inside herdr. Under tmux +--- they hand back to smart-splits: navigation through config.pane_nav, resize +--- directly, plus resize, the keys tmux.conf forwards to an +--- @pane-is-vim pane. Elsewhere are plain :resize. local nav = require "config.pane_nav" @@ -18,11 +19,20 @@ local moves = { } --- AstroNvim's key spelling again, overriding the smart-splits resize entries. +--- dir is the smart-splits direction under tmux; cmd the plain fallback. local resizes = { - [""] = { "resize +2", "Resize split taller" }, - [""] = { "resize -2", "Resize split shorter" }, - [""] = { "vertical resize -2", "Resize split narrower" }, - [""] = { "vertical resize +2", "Resize split wider" }, + [""] = { dir = "up", cmd = "resize +2", desc = "Resize split taller" }, + [""] = { dir = "down", cmd = "resize -2", desc = "Resize split shorter" }, + [""] = { dir = "left", cmd = "vertical resize -2", desc = "Resize split narrower" }, + [""] = { dir = "right", cmd = "vertical resize +2", desc = "Resize split wider" }, +} + +--- tmux.conf's vim-aware resize keys; only mapped under tmux. +local tmux_resizes = { + [""] = "left", + [""] = "down", + [""] = "up", + [""] = "right", } return { @@ -36,8 +46,18 @@ return { maps.x[key] = maps.n[key] maps.t[key] = { nav.terminal(dir), desc = desc } end + local tmux = nav.env() == "tmux" for key, spec in pairs(resizes) do - maps.n[key] = { "" .. spec[1] .. "", desc = spec[2] } + if tmux then + maps.n[key] = { function() require("smart-splits")["resize_" .. spec.dir]() end, desc = "Resize split " .. spec.dir } + else + maps.n[key] = { "" .. spec.cmd .. "", desc = spec.desc } + end + end + if tmux then + for key, dir in pairs(tmux_resizes) do + maps.n[key] = { function() require("smart-splits")["resize_" .. dir]() end, desc = "Resize split " .. dir .. " (tmux aware)" } + end end end, } diff --git a/lua/plugins/user.lua b/lua/plugins/user.lua index 78cf7f2..7c034bd 100644 --- a/lua/plugins/user.lua +++ b/lua/plugins/user.lua @@ -53,8 +53,21 @@ return { { "nvimtools/none-ls.nvim", enabled = false }, { "jay-babu/mason-null-ls.nvim", enabled = false }, - -- is config.pane_nav; resize binds are native (plugins/pane-nav.lua) - { "mrjones2014/smart-splits.nvim", enabled = false }, + -- Under tmux, smart-splits drives and resizing (config.pane_nav + -- and plugins/pane-nav.lua delegate to it) and flags the pane @pane-is-vim + -- for tmux.conf. herdr and kitty stay on config.pane_nav, so its env() picks + -- the integration instead of smart-splits' own env-var guess. Loaded at + -- startup under tmux so the flag is set before the first keypress + -- (AstroNvim's early load keys off TERM_PROGRAM, which tmux.conf passes + -- through from the outer terminal). + { + "mrjones2014/smart-splits.nvim", + lazy = require("config.pane_nav").env() ~= "tmux", + opts = function(_, opts) + opts.at_edge = "wrap" + opts.multiplexer_integration = require("config.pane_nav").env() == "tmux" and "tmux" or false + end, + }, -- lsp_signature.nvim is gone; astrolsp's own signature help replaces it { "AstroNvim/astrolsp", opts = { features = { signature_help = true } } },