Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-focus with .send? #43

Open
joshvisionalgo opened this issue May 2, 2023 · 2 comments · May be fixed by #46
Open

auto-focus with .send? #43

joshvisionalgo opened this issue May 2, 2023 · 2 comments · May be fixed by #46

Comments

@joshvisionalgo
Copy link

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.

@Npahlfer
Copy link

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",
},

@hirotasoshu hirotasoshu linked a pull request May 24, 2023 that will close this issue
@umlx5h
Copy link

umlx5h commented Sep 22, 2023

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",
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants