Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ 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)
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.
Expand Down
20 changes: 20 additions & 0 deletions lua/sidekick/cli/session/tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,34 @@ 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)
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[]
Expand Down
2 changes: 2 additions & 0 deletions lua/sidekick/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ 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)
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
Expand Down