numToStr / FTerm.nvim

:fire: No-nonsense floating terminal plugin for neovim :fire:
MIT License
721 stars 24 forks source link

Error executing lua: ...site/pack/packer/start/FTerm.nvim/lua/FTerm/terminal.lua:109: Window was closed immediately #55

Open nyngwang opened 2 years ago

nyngwang commented 2 years ago

How to Reproduce:

  1. Install plugin called fzf-lua
  2. Open any one of its floating windows, e.g. FzfLua buffers
  3. Execute cmd :lua require("FTerm").toggle()

Friendly linked to the error line: https://github.com/numToStr/FTerm.nvim/blob/eabb65f23ba48ec9e8abb9a2514f99b77b3bc6f2/lua/FTerm/terminal.lua#L109

nyngwang commented 2 years ago

For anyone who is reading try this modified keymap:

vim.keymap.set({'n', 't'}, '<M-Tab>', function ()
  if (vim.api.nvim_win_get_config(0).relative ~= '') then
    vim.api.nvim_input('<ESC>')
  end
  require('FTerm').toggle()
end, NOREF_NOERR_TRUNC)

the little non-harmful drawback is that you will need to press the keymap twice to close the existing floating window and open the terminal.

nyngwang commented 2 years ago

I hope this can be taken into consideration. So users won't have to solve it themselves painly.

numToStr commented 2 years ago

I'll investigate what is causing this.

nyngwang commented 2 years ago

I'll investigate what is causing this.

@numToStr Thanks :)

For anyone who is reading try this modified keymap:

vim.keymap.set({'n', 't'}, '<M-Tab>', function ()
  if (vim.api.nvim_win_get_config(0).relative ~= '') then
    vim.api.nvim_input('<ESC>')
  end
  require('FTerm').toggle()
end, NOREF_NOERR_TRUNC)

And I just found a much simpler solution hours ago. But this one doesn't facilitate the newest syntax. It still need to use <cmd>..., which is what I don't like:

vim.keymap.set({'n', 't'}, '<M-Tab>', "<cmd>silent! lua require('FTerm').toggle()<CR>", { nowait=true, noremap=true, silent=true })
marcoSven commented 8 months ago

Friendly linked to the error line:

https://github.com/numToStr/FTerm.nvim/blob/eabb65f23ba48ec9e8abb9a2514f99b77b3bc6f2/lua/FTerm/terminal.lua#L109

I am running into the same issue with Telescope.