voldikss / vim-floaterm

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

Custom width, height, position on FloatTermToggle #409

Open shivkar2n opened 1 year ago

shivkar2n commented 1 year ago

Hey first of all thanks for the awesome plugin!

I usually have a vs-code style terminal docked at the bottom of my editor which is called by command

:FloatermNew --height=0.4 --width=1.0 --wintype=float --position=bottom --autoclose=2

But when I run :FloatermToggle with no float-terminal initially open, it create a new floating terminal with the default properties.

Is there a way to toggle so that if no terminal exists then it opens one as specified above?

1332927388 commented 1 year ago

+1

nabaco commented 3 months ago

Agreed. For now, this is how I configured it in Lua (using Lazy.nvim) in my Neovim setup:

keys = {
    "<leader>`",
    function()
        if vim.fn["floaterm#terminal#get_bufnr"]("quake") < 0 then
            vim.cmd.FloatermNew({
                "--height=0.3",
                "--wintype=split",
                "--name=quake",
                "--autoclose=2",
                "--title=Quake"
            })
        else
            vim.cmd.FloatermToggle("quake")
        end
    end,
    mode = {'n', 'i', 't'},
    desc="Quake terminal"
}

It checks whether a terminal with a given name exists already, and acts accordingly