zbirenbaum / nvterm

NvChad's Official Terminal Plugin ( Unmaintained but still usable and stable), wait for v3.0
GNU General Public License v3.0
181 stars 20 forks source link

Lazygit integration #29

Closed Parry-97 closed 1 year ago

Parry-97 commented 1 year ago

Hi, I tried using the send function for this and the command is successfully executed inside the spawned terminal but I can't insert on that specific terminal and the focus remains on the previously active buffer. have to toggle back to the terminal in order to work on it. Is there another alternative to send to execute the command and to work on the terminal in insert mode ?

Very simple mapping on my side: image

AllanChain commented 1 year ago

nvterm deliberately restores focus after sending the command to the terminal:

https://github.com/NvChad/nvterm/blob/29a70ef608a8cc5db3a5fc300d39a39d1a44a863/lua/nvterm/terminal.lua#L65-L80

A workaround is to use the following:

    ["<leader>gg"] = {
      function()
        local term = require("nvterm.terminal").new("float")
        vim.api.nvim_chan_send(term.job_id, "lazygit\n")
      end,
      "open Lazygit",
    },
Parry-97 commented 1 year ago

Thanks, @AllanChain .