-
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Thanks for exposing the methods necessary to be able to do this.
Is having this functionality built-in within scope of this project?
If so, let me know of any parameters/constraints I should be aware of before making the PR.
local function run_in_floaterm(opts)
local buf = 0
-- open first, otherwise window_id's dont exist and `switch_buf` will fail
require("floaterm").open()
for _, term in ipairs(require("floaterm.state").terminals) do
if term.name == opts.name then
buf = term.buf
break
end
end
if buf == 0 then
require("floaterm.api").new_term({ cmd = opts.cmd, name = opts.name })
else
require("floaterm.api").send_cmd({ cmd = opts.cmd, buf = buf })
require("floaterm.utils").switch_buf(buf)
end
end
vim.keymap.set("n", "<leader>gP", function()
run_in_floaterm({ name = "Git", cmd = "git push" })
end, { desc = "Floaterm: Git Push" })Could maybe be exposed as:
require("floaterm.api").open_and_run({ name = "Git", cmd = "git push"})Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels