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 3e8cef4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lua/neoterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,35 @@ function neoterm.open(opts)
border = "single",
}

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
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 3e8cef4

Please sign in to comment.