diff --git a/lua/which-key/layout.lua b/lua/which-key/layout.lua index ee9b1feb..b8c1a792 100644 --- a/lua/which-key/layout.lua +++ b/lua/which-key/layout.lua @@ -7,7 +7,7 @@ local dw = vim.fn.strdisplaywidth --- Otherwise, it is a percentage of `parent` (relative size). --- If `size` is negative, it is subtracted from `parent`. --- If `size` is a table, it is a range of values. ----@alias wk.Dim number|{min:number, max:number} +---@alias wk.Dim number|{min:number, max:number}|function ---@param size number ---@param parent number @@ -17,6 +17,9 @@ function M.dim(size, parent, ...) size = math.abs(size) < 1 and parent * size or size size = size < 0 and parent + size or size for _, dim in ipairs({ ... } --[[ @as wk.Dim[] ]]) do + if type(dim) == "function" then + dim = dim() + end if type(dim) == "number" then size = M.dim(dim, parent) else diff --git a/lua/which-key/win.lua b/lua/which-key/win.lua index 5a1ccf9c..d68b3e3d 100644 --- a/lua/which-key/win.lua +++ b/lua/which-key/win.lua @@ -9,7 +9,6 @@ M.__index = M ---@class wk.Win.opts local override = { - relative = "editor", style = "minimal", focusable = false, noautocmd = true, @@ -29,7 +28,12 @@ local override = { } ---@type wk.Win.opts -local defaults = { col = 0, row = math.huge, zindex = 1000 } +local defaults = { + relative = "editor", + col = 0, + row = math.huge, + zindex = 1000 +} ---@param opts? wk.Win.opts function M.defaults(opts)