numToStr / FTerm.nvim

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

Can't background an FTerm terminal running `k9s` #84

Open jessebot opened 1 year ago

jessebot commented 1 year ago

Thanks for maintaining FTerm.nvim! It's a really cool project :)

I use k9s to monitor my kubernetes clusters in the terminal, and was previously using nvim-k8s to launch a floating window in neovim with k9s running in it. I wanted to consolidate my plugins and use fterm for k9s instead, because nvim-k8s is not actively maintained right now anyway. Here's what I put together in my lua config:

local fterm = require("FTerm")

-- must install k9s in advance, see: https://k9scli.io/topics/install/
local k9s = fterm:new({
    ft = 'fterm_k9s',
    cmd = "k9s",
    dimensions = {
        height = 0.9,
        width = 0.9
    }
})

-- Use this to toggle k9s in a floating terminal
-- first arg of 'n' is for normal mode in neovim
-- <A-b> are keys: Alt + b (alt is option on macOS)
vim.keymap.set('n', '<A-b>', function()
    k9s:toggle()
end)

Launching k9s in a floating terminal with Alt+b works fine, but I can't background it with the same key combination and I'm not sure why. I think k9s is capturing the key input, but I'm not really sure how to fix this. I know in nvim-k8s they used the keys Alt+p for toggling the floating window, and that worked fine, but I have no idea why it doesn't work for fterm.

I tried with Alt+p instead of the config above and I get the same result of it working for opening the terminal, but not for backgrounding it.

Do you have any ideas on how to solve this? It doesn't look like k9s is actually using Alt for anything according to their docs, so I'm a bit confused 🤔