diff --git a/README.md b/README.md index 36d55a8..6992b66 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,8 @@ return { colorscheme = { "habamax" }, }, ui = { + -- a number <1 is a percentage., >1 is a fixed size + size = { width = 0.8, height = 0.8 }, -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|. border = "none", icons = { diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 5e1745f..9ddbfa3 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -32,6 +32,8 @@ M.defaults = { colorscheme = { "habamax" }, }, ui = { + -- a number <1 is a percentage., >1 is a fixed size + size = { width = 0.8, height = 0.8 }, -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|. border = "none", icons = { diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index b440620..9f7ed69 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -56,16 +56,19 @@ function M.show(mode) local buf = vim.api.nvim_create_buf(false, false) M._buf = buf - local vpad = 6 - local hpad = 20 + + local function size(max, value) + return value > 1 and math.min(value, max) or math.floor(max * value) + end local opts = { relative = "editor", style = "minimal", border = Config.options.ui.border, - width = math.min(vim.o.columns - hpad * 2, 200), - height = math.min(vim.o.lines - vpad * 2, 70), + width = size(vim.o.columns, Config.options.ui.size.width), + height = size(vim.o.lines, Config.options.ui.size.height), noautocmd = true, } + opts.row = (vim.o.lines - opts.height) / 2 opts.col = (vim.o.columns - opts.width) / 2 local win = vim.api.nvim_open_win(buf, true, opts)