fix: float positioning and width calculation (#32)
This commit is contained in:
parent
6062ad6737
commit
f8ca564802
1 changed files with 5 additions and 2 deletions
|
|
@ -219,6 +219,9 @@ M.open_float = function(dir)
|
||||||
local total_width = vim.o.columns
|
local total_width = vim.o.columns
|
||||||
local total_height = util.get_editor_height()
|
local total_height = util.get_editor_height()
|
||||||
local width = total_width - 2 * config.float.padding
|
local width = total_width - 2 * config.float.padding
|
||||||
|
if config.float.border ~= "none" then
|
||||||
|
width = width - 2 -- The border consumes 1 col on each side
|
||||||
|
end
|
||||||
if config.float.max_width > 0 then
|
if config.float.max_width > 0 then
|
||||||
width = math.min(width, config.float.max_width)
|
width = math.min(width, config.float.max_width)
|
||||||
end
|
end
|
||||||
|
|
@ -226,8 +229,8 @@ M.open_float = function(dir)
|
||||||
if config.float.max_height > 0 then
|
if config.float.max_height > 0 then
|
||||||
height = math.min(height, config.float.max_height)
|
height = math.min(height, config.float.max_height)
|
||||||
end
|
end
|
||||||
local row = math.floor((total_width - width) / 2)
|
local row = math.floor((total_height - height) / 2)
|
||||||
local col = math.floor((total_height - height) / 2)
|
local col = math.floor((total_width - width) / 2) - 1 -- adjust for border width
|
||||||
local winid = vim.api.nvim_open_win(bufnr, true, {
|
local winid = vim.api.nvim_open_win(bufnr, true, {
|
||||||
relative = "editor",
|
relative = "editor",
|
||||||
width = width,
|
width = width,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue