feat(pane-nav): smart-splits under tmux, pane_nav for herdr/kitty
This commit is contained in:
1 parent
3a0e1cb13e
commit
7d448348b2
4 files changed
+50
-13
No files matched your search
@@ -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
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
--- <C-h/j/k/l> 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 <C-Up/Down/Left/Right> 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 <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.
|
||||
|
||||
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 = {
|
||||
["<C-Up>"] = { "resize +2", "Resize split taller" },
|
||||
["<C-Down>"] = { "resize -2", "Resize split shorter" },
|
||||
["<C-Left>"] = { "vertical resize -2", "Resize split narrower" },
|
||||
["<C-Right>"] = { "vertical resize +2", "Resize split wider" },
|
||||
["<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",
|
||||
}
|
||||
|
||||
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] = { "<Cmd>" .. spec[1] .. "<CR>", 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] = { "<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
|
||||
end
|
||||
end,
|
||||
}
|
||||
+15
-2
@@ -53,8 +53,21 @@ return {
|
||||
{ "nvimtools/none-ls.nvim", enabled = false },
|
||||
{ "jay-babu/mason-null-ls.nvim", enabled = false },
|
||||
|
||||
-- <C-h/j/k/l> is config.pane_nav; resize binds are native (plugins/pane-nav.lua)
|
||||
{ "mrjones2014/smart-splits.nvim", enabled = false },
|
||||
-- Under tmux, smart-splits drives <C-h/j/k/l> 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 } } },
|
||||
|
||||
Reference in new issue
Block a user