fix(ui): take border into account for window position. Fixes #812

This commit is contained in:
Folke Lemaitre 2023-05-21 20:51:41 +02:00
parent 5f316cea4f
commit 451f217e9b
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 6 additions and 1 deletions

View File

@ -35,7 +35,7 @@ function M:init(opts)
self.opts = vim.tbl_deep_extend("force", {
size = Config.options.ui.size,
style = "minimal",
border = Config.options.ui.border,
border = Config.options.ui.border or "none",
zindex = 50,
}, opts or {})
@ -66,6 +66,11 @@ function M:layout()
self.win_opts.row = math.floor((vim.o.lines - self.win_opts.height) / 2)
self.win_opts.col = math.floor((vim.o.columns - self.win_opts.width) / 2)
if self.opts.border ~= "none" then
self.win_opts.row = self.win_opts.row - 1
self.win_opts.col = self.win_opts.col - 1
end
if self.opts.margin then
if self.opts.margin.top then
self.win_opts.height = self.win_opts.height - self.opts.margin.top