Skip to content

Commit

Permalink
feat(ui): make the windoww size configurable. Fixes #34
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 20, 2022
1 parent 5298441 commit 941df31
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
11 changes: 7 additions & 4 deletions lua/lazy/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 941df31

Please sign in to comment.