mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(win): width/height can now be a function
This commit is contained in:
parent
1f74d1ce77
commit
964d7ae99a
1 changed files with 4 additions and 2 deletions
|
@ -21,8 +21,8 @@ local M = setmetatable({}, {
|
|||
---@class snacks.win.Config: vim.api.keyset.win_config
|
||||
---@field style? string merges with config from `Snacks.config.styles[style]`
|
||||
---@field show? boolean Show the window immediately (default: true)
|
||||
---@field height? number Height of the window. Use <1 for relative height. 0 means full height. (default: 0.9)
|
||||
---@field width? number Width of the window. Use <1 for relative width. 0 means full width. (default: 0.9)
|
||||
---@field height? number|fun():number Height of the window. Use <1 for relative height. 0 means full height. (default: 0.9)
|
||||
---@field width? number|fun():number Width of the window. Use <1 for relative width. 0 means full width. (default: 0.9)
|
||||
---@field minimal? boolean Disable a bunch of options to make the window minimal (default: true)
|
||||
---@field position? "float"|"bottom"|"top"|"left"|"right"
|
||||
---@field buf? number If set, use this buffer instead of creating a new one
|
||||
|
@ -573,6 +573,8 @@ function M:win_opts()
|
|||
opts[k] = self.opts[k]
|
||||
end
|
||||
local parent = self:parent_size()
|
||||
opts.height = type(opts.height) == "function" and opts.height() or opts.height
|
||||
opts.width = type(opts.width) == "function" and opts.width() or opts.width
|
||||
-- Special case for 0, which means 100%
|
||||
opts.height = opts.height == 0 and parent.height or opts.height
|
||||
opts.width = opts.width == 0 and parent.width or opts.width
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue