Skip to content

Commit

Permalink
Runner support for tmux v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NonlinearFruit committed Jan 31, 2024
1 parent dfa90e5 commit ea947a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 0 additions & 2 deletions nvim/lua/jqplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@ local function Run_jq(cmd)
local opts = {
stdin = "null",
on_stdout = function(_, msg)
local output = table.concat(msg, "\n")
vim.fn.appendbufline(out_buf, "$", msg)
end,
on_stderr = function(_, msg)
if msg[1] == "" then
return
end
local output = table.concat(msg, "\n")
vim.fn.appendbufline(out_buf, "$", "// " .. msg)
vim.fn.appendbufline(out_buf, "$", "// " .. jq_cmd)
end,
Expand Down
28 changes: 23 additions & 5 deletions nvim/lua/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,33 @@ M.prompt = function()
M.run(cmd)
end

M.run = function(cmd)
M.createIfNoRunner = function()
local runner = M.getId()
if runner == "" then
os.execute("tmux split-window -l 40% -h")
local job = vim.fn.jobstart("tmux -V", {
stdout_buffered = true,
on_stdout = function(_, data)
local version = data[1]
print(version)
print(string.sub(version, 6, 8))
if string.sub(version, 6, 8) == "3.0" then
os.execute("tmux split-window -p 40 -h")
else
os.execute("tmux split-window -l 40% -h")
end
end,
})
vim.fn.jobwait({ job })
os.execute("tmux last-pane")
runner = M.getId()
if runner == "" then
return
end
end
return runner
end

M.run = function(cmd)
local runner = M.createIfNoRunner()
if runner == "" then
return
end
os.execute("tmux send-keys -t " .. runner .. " '" .. cmd .. "' ENTER")
end
Expand Down

0 comments on commit ea947a0

Please sign in to comment.