From 972b3e1859fcfe47a55a1095824dc7dafebeb7bb Mon Sep 17 00:00:00 2001 From: Noah Bauer Date: Thu, 23 Jul 2026 12:54:33 +0200 Subject: [PATCH 1/2] feat: add split before option --- README.md | 1 + lua/sidekick/cli/session/tmux.lua | 3 +++ lua/sidekick/config.lua | 1 + 3 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 675ee135..cef78ecd 100644 --- a/README.md +++ b/README.md @@ -326,6 +326,7 @@ local defaults = { create = "terminal", ---@type "terminal"|"window"|"split" split = { vertical = true, -- vertical or horizontal split + before = false, -- place the split before the current pane (left when vertical, above when horizontal) size = 0.5, -- size of the split (0-1 for percentage) }, }, diff --git a/lua/sidekick/cli/session/tmux.lua b/lua/sidekick/cli/session/tmux.lua index 95dbbb48..9c98ca38 100644 --- a/lua/sidekick/cli/session/tmux.lua +++ b/lua/sidekick/cli/session/tmux.lua @@ -44,6 +44,9 @@ function M:start() elseif Config.cli.mux.create == "split" then local cmd = { "tmux", "split-window", "-dP", "-c", self.cwd, "-F", PANE_FORMAT } cmd[#cmd + 1] = Config.cli.mux.split.vertical and "-h" or "-v" + if Config.cli.mux.split.before then + cmd[#cmd + 1] = "-b" + end local size = Config.cli.mux.split.size vim.list_extend(cmd, { "-l", tostring(size <= 1 and ((size * 100) .. "%") or size) }) self:add_cmd(cmd) diff --git a/lua/sidekick/config.lua b/lua/sidekick/config.lua index d30e92e8..c6a95c8f 100644 --- a/lua/sidekick/config.lua +++ b/lua/sidekick/config.lua @@ -93,6 +93,7 @@ local defaults = { create = "terminal", ---@type "terminal"|"window"|"split" split = { vertical = true, -- vertical or horizontal split + before = false, -- place the split before the current pane (left when vertical, above when horizontal) size = 0.5, -- size of the split (0-1 for percentage) }, -- max lines to capture when dumping a multiplexer pane for scrollback support From 23164f7c743156781fa09c9bbad3754baf094092 Mon Sep 17 00:00:00 2001 From: Noah Bauer Date: Thu, 23 Jul 2026 13:04:26 +0200 Subject: [PATCH 2/2] feat: add close_on_exit option --- README.md | 1 + lua/sidekick/cli/session/tmux.lua | 17 +++++++++++++++++ lua/sidekick/config.lua | 1 + 3 files changed, 19 insertions(+) diff --git a/README.md b/README.md index cef78ecd..05ce50c6 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,7 @@ local defaults = { vertical = true, -- vertical or horizontal split before = false, -- place the split before the current pane (left when vertical, above when horizontal) size = 0.5, -- size of the split (0-1 for percentage) + close_on_exit = false, -- close the split when Neovim exits }, }, --- Actual cli tool config is loaded from the runtime path `sk/cli/{tool}.lua` and merged with the config below. diff --git a/lua/sidekick/cli/session/tmux.lua b/lua/sidekick/cli/session/tmux.lua index 9c98ca38..d20c5272 100644 --- a/lua/sidekick/cli/session/tmux.lua +++ b/lua/sidekick/cli/session/tmux.lua @@ -51,10 +51,27 @@ function M:start() vim.list_extend(cmd, { "-l", tostring(size <= 1 and ((size * 100) .. "%") or size) }) self:add_cmd(cmd) self:spawn(cmd) + if Config.cli.mux.split.close_on_exit then + self:close_on_exit() + end Util.info(("Started **%s** in a new tmux split"):format(self.tool.name)) end end +--- Kill the tmux pane when Neovim exits. +function M:close_on_exit() + local pane_id = self.tmux_pane_id + if not pane_id then + return + end + vim.api.nvim_create_autocmd("VimLeavePre", { + once = true, + callback = function() + pcall(Util.exec, { "tmux", "kill-pane", "-t", pane_id }, { notify = false }) + end, + }) +end + --- Execute the given tmux command and update the session info, --- based on the first pane returned. ---@param cmd string[] diff --git a/lua/sidekick/config.lua b/lua/sidekick/config.lua index c6a95c8f..a6f1bfb7 100644 --- a/lua/sidekick/config.lua +++ b/lua/sidekick/config.lua @@ -95,6 +95,7 @@ local defaults = { vertical = true, -- vertical or horizontal split before = false, -- place the split before the current pane (left when vertical, above when horizontal) size = 0.5, -- size of the split (0-1 for percentage) + close_on_exit = false, -- close the split when Neovim exits }, -- max lines to capture when dumping a multiplexer pane for scrollback support -- more lines means slower loading of the scrollback