akinsho / toggleterm.nvim

A neovim lua plugin to help easily manage multiple terminal windows
GNU General Public License v3.0
4.21k stars 170 forks source link

[FR]: Allow `Terminal:new()` to take custom `width` and `height` #539

Closed ls-devs closed 7 months ago

ls-devs commented 7 months ago

Hi,

I wonder if it's possible to make creation of custom terminal take a custom width and height.

For example :

    local Terminal = require("toggleterm.terminal").Terminal
    local lazygit = Terminal:new({
        cmd = "lazygit",
        direction = "float",
        width = 0.8, -- <-- Here
        height = 0.8, -- <-- Here
        on_open = function(term)
            local keymap = vim.api.nvim_buf_set_keymap
            keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
            keymap(term.bufnr, "t", "<esc>", "<cmd>close<CR>", { noremap = true, silent = true })
        end,
    })
    return lazygit:toggle()
PMassicotte commented 6 months ago

Sorry to hijack this, but is it possible to set the width when using direction = "vertical" ?

I have tried this, but the terminal opens on the left without any effect of the width argument.

local duckdb = Terminal:new({
    cmd = "duckdb",
    direction = "vertical",
    width = 10,
})