2026-08-15 13:47:41 -04:00
|
|
|
--- <C-h/j/k/l> pane navigation that follows whatever multiplexer Neovim is
|
|
|
|
|
--- running under (herdr, tmux, or bare kitty) — see config.pane_nav.
|
|
|
|
|
---
|
2026-11-02 10:46:21 -05:00
|
|
|
--- 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 <M-h/j/k/l> resize, the keys tmux.conf forwards to an
|
|
|
|
|
--- @pane-is-vim pane. Elsewhere <C-Up/Down/Left/Right> are plain :resize.
|
2026-08-15 13:47:41 -04:00
|
|
|
|
|
|
|
|
local nav = require "config.pane_nav"
|
|
|
|
|
|
|
|
|
|
--- AstroNvim's key spelling for these chords, so the entries overwrite rather
|
|
|
|
|
--- than race the smart-splits / term_nav mappings.
|
|
|
|
|
local moves = {
|
|
|
|
|
["<C-H>"] = "left",
|
|
|
|
|
["<C-J>"] = "down",
|
|
|
|
|
["<C-K>"] = "up",
|
|
|
|
|
["<C-L>"] = "right",
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 09:39:10 -04:00
|
|
|
--- AstroNvim's key spelling again, overriding the smart-splits resize entries.
|
2026-11-02 10:46:21 -05:00
|
|
|
--- dir is the smart-splits direction under tmux; cmd the plain fallback.
|
2026-10-18 09:39:10 -04:00
|
|
|
local resizes = {
|
2026-11-02 10:46:21 -05:00
|
|
|
["<C-Up>"] = { dir = "up", cmd = "resize +2", desc = "Resize split taller" },
|
|
|
|
|
["<C-Down>"] = { dir = "down", cmd = "resize -2", desc = "Resize split shorter" },
|
|
|
|
|
["<C-Left>"] = { dir = "left", cmd = "vertical resize -2", desc = "Resize split narrower" },
|
|
|
|
|
["<C-Right>"] = { dir = "right", cmd = "vertical resize +2", desc = "Resize split wider" },
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
--- tmux.conf's vim-aware resize keys; only mapped under tmux.
|
|
|
|
|
local tmux_resizes = {
|
|
|
|
|
["<M-h>"] = "left",
|
|
|
|
|
["<M-j>"] = "down",
|
|
|
|
|
["<M-k>"] = "up",
|
|
|
|
|
["<M-l>"] = "right",
|
2026-10-18 09:39:10 -04:00
|
|
|
}
|
|
|
|
|
|
2026-08-15 13:47:41 -04:00
|
|
|
return {
|
|
|
|
|
"AstroNvim/astrocore",
|
|
|
|
|
opts = function(_, opts)
|
|
|
|
|
local maps = opts.mappings
|
2026-10-13 09:07:58 -04:00
|
|
|
maps.x = maps.x or {}
|
2026-08-15 13:47:41 -04:00
|
|
|
for key, dir in pairs(moves) do
|
|
|
|
|
local desc = ("Move %s a split (%s aware)"):format(dir, nav.env())
|
|
|
|
|
maps.n[key] = { function() nav.navigate(dir) end, desc = desc }
|
2026-10-13 09:07:58 -04:00
|
|
|
maps.x[key] = maps.n[key]
|
2026-08-15 13:47:41 -04:00
|
|
|
maps.t[key] = { nav.terminal(dir), desc = desc }
|
|
|
|
|
end
|
2026-11-02 10:46:21 -05:00
|
|
|
local tmux = nav.env() == "tmux"
|
2026-10-18 09:39:10 -04:00
|
|
|
for key, spec in pairs(resizes) do
|
2026-11-02 10:46:21 -05:00
|
|
|
if tmux then
|
|
|
|
|
maps.n[key] = { function() require("smart-splits")["resize_" .. spec.dir]() end, desc = "Resize split " .. spec.dir }
|
|
|
|
|
else
|
|
|
|
|
maps.n[key] = { "<Cmd>" .. spec.cmd .. "<CR>", 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
|
2026-10-18 09:39:10 -04:00
|
|
|
end
|
2026-08-15 13:47:41 -04:00
|
|
|
end,
|
|
|
|
|
}
|