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
14 changes: 10 additions & 4 deletions lua/opencode/provider/tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,27 @@ function Tmux:start()
if not pane_id then
-- Create new pane
local detach_flag = self.opts.focus and "" or "-d"
self.pane_id = vim.fn.system(
string.format("tmux split-window %s -P -F '#{pane_id}' %s '%s'", detach_flag, self.opts.options or "", self.cmd)
self.pane_id = vim.trim(
vim.fn.system(
string.format("tmux split-window %s -P -F '#{pane_id}' %s '%s'", detach_flag, self.opts.options or "", self.cmd)
)
)
local disable_passthrough = self.opts.allow_passthrough ~= true -- default true (disable passthrough)
if disable_passthrough and self.pane_id and self.pane_id ~= "" then
vim.fn.system(string.format("tmux set-option -t %s -p allow-passthrough off", vim.trim(self.pane_id)))
vim.fn.system(string.format("tmux set-option -t %s -p allow-passthrough off", self.pane_id))
end
end
end

---Kill the `opencode` pane.
---Kill the `opencode` pane and its process.
function Tmux:stop()
local pane_id = self:get_pane_id()
if pane_id then
local pid = vim.trim(vim.fn.system("tmux display-message -t " .. pane_id .. " -p '#{pane_pid}'"))
vim.fn.system("tmux kill-pane -t " .. pane_id)
if pid ~= "" and tonumber(pid) then
vim.fn.system({ "kill", pid })
end
self.pane_id = nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion plugin/provider.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vim.api.nvim_create_autocmd("VimLeave", {
vim.api.nvim_create_autocmd("VimLeavePre", {
group = vim.api.nvim_create_augroup("OpencodeProvider", { clear = true }),
pattern = "*",
callback = function()
Expand Down