Open joshvisionalgo opened 1 year ago
I encountered the same problem and went with this for the time being:
["<leader>gg"] = {
function()
local nvterm = require "nvterm.terminal"
local terminal = nvterm.new "float"
local id = terminal.job_id
-- The previous id was not always right for some reason so I made a fallback,
-- as you can only have one floating terminal
for _, term in pairs(nvterm.list_terms()) do
if term.type == "float" then
id = term.job_id
end
end
if vim.api.nvim_buf_is_valid(id) then
vim.api.nvim_chan_send(id, "lazygit && exit\n")
end
end,
"Open Lazygit",
},
I could not get it to work this way with an error. It seems to be possible if it is not a float.
Instead, I used the following silly method.
["<leader>gg"] = {
function()
local nvterm = require "nvterm.terminal"
nvterm.send("lazygit && exit", "float")
nvterm.toggle "float"
nvterm.toggle "float"
end,
"Open lazygit",
},
Loving nvterm. I have mapped a binding to use .send to run lazygit in a new term. Is there a way to assign focus to the term when using .send? I noticed auto-focus works when using .toggle or .new, but not .send.