Skip to content

Commit

Permalink
Fix terminal going offscreen in neovide in top/bottom/fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
dpi0 committed Sep 26, 2024
1 parent 7d2d9b9 commit 6962317
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lua/neoterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ local config = {
clear_on_run = true,
position = "right", -- Default position is right
noinsert = false,
width = 0.5, -- Default width is 50%
height = 1, -- Default height is 100%
width = 0.5, -- Default width is 50%
height = 1, -- Default height is 100%
}

-- Returns a bool to show if the neoterm window exists
Expand Down Expand Up @@ -154,33 +154,35 @@ function neoterm.open(opts)
border = "single",
}

if position == 0 then -- fullscreen
winopts.width = ui.width
local width_padding = 2 -- Add some padding so that terminal fits within the visible area (neovide)

if position == 0 then -- fullscreen
winopts.width = ui.width - width_padding
winopts.height = ui.height - vim.o.cmdheight - 3
winopts.row = 0
winopts.col = 0
elseif position == 1 then -- top
winopts.width = ui.width
winopts.width = ui.width - width_padding
winopts.height = math.floor(ui.height * height) - vim.o.cmdheight - 3
winopts.row = 0
winopts.col = 0
elseif position == 2 then -- right
winopts.width = math.floor(ui.width * width)
winopts.width = math.floor(ui.width * width) - width_padding
winopts.height = ui.height - vim.o.cmdheight - 3
winopts.row = 0
winopts.col = ui.width - winopts.width
elseif position == 3 then -- bottom
winopts.width = ui.width
winopts.width = ui.width - width_padding
winopts.height = math.floor(ui.height * height) - vim.o.cmdheight - 3
winopts.row = ui.height - winopts.height - vim.o.cmdheight - 3
winopts.col = 0
elseif position == 4 then -- left
winopts.width = math.floor(ui.width * width)
winopts.width = math.floor(ui.width * width) - width_padding
winopts.height = ui.height - vim.o.cmdheight - 3
winopts.row = 0
winopts.col = 0
elseif position == 5 then -- center
winopts.width = math.floor(ui.width * width)
winopts.width = math.floor(ui.width * width) - width_padding
winopts.height = math.floor(ui.height * height) - vim.o.cmdheight - 3
winopts.row = math.floor((ui.height - winopts.height) / 2)
winopts.col = math.floor((ui.width - winopts.width) / 2)
Expand Down

0 comments on commit 6962317

Please sign in to comment.