Skip to content

How to create a dynamically sized terminal #658

@redbeardymcgee

Description

@redbeardymcgee

I have the following function for my size value:

                size = function(term)
                    if term.direction == "horizontal" then
                        return math.floor(vim.o.lines * 0.4)
                    elseif term.direction == "vertical" then
                        return math.floor(vim.o.columns * 0.4)
                    end
                end,

This correctly determines 40% of the window size either horizontal or vertical, and the resulting terminal is spawned with the expected size. Toggling this terminal does not detect any size changes, but I think that is to be expected unless I change the settings for the toggling functionality to re-detect and resize accordingly.

However, when this terminal is killed completely rather than simply hidden (toggled off), I expect the next terminal to be sized according to the current size of the window. Unfortunately, every new terminal is spawned with the old value instead, resulting in terminals that are less than 40% wide or tall with respect to the current window. This issue also applies to floating terminals, making all types of terminals practically unusable without manually resizing them after changing the size of my editor window.

I run into this frequently because I still use tmux for a variety of reasons that neovim terminals in my current editor don't make sense for, such as a second nvim instance for testing config changes. Is there some way to automatically resize toggled terminals according to the current window size already? I couldn't find any mention of it in the readme, wiki or issues, but it's easy to overlook.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions