voldikss / vim-floaterm

:computer: Terminal manager for (neo)vim
MIT License
2.46k stars 79 forks source link

Prevent focusing away? #417

Closed 9mm closed 10 months ago

9mm commented 10 months ago

Question

I'm doing a simple lazygit floaterm, and sometimes I will accidentally hit some key and the window loses focus. This is very annoying to have to do several times until i can finally get the proper window highlighted.

Is there a way just to make it where the window never is able to lose focus unless i explicitly close it with q (lazygit quit command)

Environment

If you are using vim(not neovim), fill in the following blanks

If you are using neovim, just run :checkhealth floaterm and post the content

below.

floaterm: health#floaterm#check

common ~
- Platform: macos
- Nvim: NVIM v0.9.2
- Plugin: eeb3f6b

terminal ~
- OK Terminal emulator is available

floating ~
- OK Floating window is available

Configurations related to vim-floaterm in vimrc(i.e. g:floaterm_xxx):

return {
  'voldikss/vim-floaterm',
  keys = {
    {
      '<Leader>x',
      function() vim.cmd('FloatermNew --title=ZSH --floaterm_autoclose=2 --width=0.7 --height=0.4') end,
      desc = 'ZSH shell',
    },
    {
      '<Leader>z',
      function() vim.cmd('FloatermNew --title=LazyGit --width=0.95 --height=0.95 lazygit') end,
      desc = 'LazyGit',
    },
  },
}
9mm commented 10 months ago

OK after more digging............

Simply MOVING the mouse outside the window is enough to get lazyvim to no longer listen to "q"

As soon as i open lazygit, in the status line it says --TERMINAL

When i move the mouse outside the window (even if i dont click)

The status line stop clears out and no longer says --TERMINAL, AND... now lazygit stops responding to all commands

i have to mash c-wc-wc-wc-w 4 times to re-focus it

i tried with just a standard terminal and i notice if i mouse back in it DOES let me type again. so is there somethign weird going on with lazygit that prevents it from "refocusing"

Can i entirely disable this focusing behavior? theres no situation where i want to use the mouse to make a window lose focus in a floaterm window... maybe a diagnostic window or something, but not a floatterm

9mm commented 10 months ago

Hmm... im pretty sure this is a bug with the Neovim GUI im using, which is not properly focusing floating windows. I notice this happens when using plenary as well, so I dont think this is a floaterm issue