Skip to content

Commit 941df31

Browse files
committed
feat(ui): make the windoww size configurable. Fixes #34
1 parent 5298441 commit 941df31

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ return {
263263
colorscheme = { "habamax" },
264264
},
265265
ui = {
266+
-- a number <1 is a percentage., >1 is a fixed size
267+
size = { width = 0.8, height = 0.8 },
266268
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
267269
border = "none",
268270
icons = {

lua/lazy/core/config.lua

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ M.defaults = {
3232
colorscheme = { "habamax" },
3333
},
3434
ui = {
35+
-- a number <1 is a percentage., >1 is a fixed size
36+
size = { width = 0.8, height = 0.8 },
3537
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
3638
border = "none",
3739
icons = {

lua/lazy/view/init.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,19 @@ function M.show(mode)
5656

5757
local buf = vim.api.nvim_create_buf(false, false)
5858
M._buf = buf
59-
local vpad = 6
60-
local hpad = 20
59+
60+
local function size(max, value)
61+
return value > 1 and math.min(value, max) or math.floor(max * value)
62+
end
6163
local opts = {
6264
relative = "editor",
6365
style = "minimal",
6466
border = Config.options.ui.border,
65-
width = math.min(vim.o.columns - hpad * 2, 200),
66-
height = math.min(vim.o.lines - vpad * 2, 70),
67+
width = size(vim.o.columns, Config.options.ui.size.width),
68+
height = size(vim.o.lines, Config.options.ui.size.height),
6769
noautocmd = true,
6870
}
71+
6972
opts.row = (vim.o.lines - opts.height) / 2
7073
opts.col = (vim.o.columns - opts.width) / 2
7174
local win = vim.api.nvim_open_win(buf, true, opts)

0 commit comments

Comments
 (0)