mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-06 11:48:23 +00:00
feat(zen): added on_open / on_close callbacks
This commit is contained in:
parent
54294cba6a
commit
5851de157a
1 changed files with 8 additions and 1 deletions
|
@ -29,7 +29,12 @@ local defaults = {
|
||||||
},
|
},
|
||||||
---@type snacks.win.Config
|
---@type snacks.win.Config
|
||||||
win = { style = "zen" },
|
win = { style = "zen" },
|
||||||
|
--- Callback when the window is opened.
|
||||||
|
---@param win snacks.win
|
||||||
|
on_open = function(win) end,
|
||||||
|
--- Callback when the window is closed.
|
||||||
|
---@param win snacks.win
|
||||||
|
on_close = function(win) end,
|
||||||
--- Options for the `Snacks.zen.zoom()`
|
--- Options for the `Snacks.zen.zoom()`
|
||||||
---@type snacks.zen.Config
|
---@type snacks.zen.Config
|
||||||
zoom = {
|
zoom = {
|
||||||
|
@ -158,6 +163,7 @@ function M.zen(opts)
|
||||||
toggle:set(state)
|
toggle:set(state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
opts.on_open(win)
|
||||||
|
|
||||||
-- restore toggle states when window is closed
|
-- restore toggle states when window is closed
|
||||||
vim.api.nvim_create_autocmd("WinClosed", {
|
vim.api.nvim_create_autocmd("WinClosed", {
|
||||||
|
@ -170,6 +176,7 @@ function M.zen(opts)
|
||||||
for _, state in ipairs(states) do
|
for _, state in ipairs(states) do
|
||||||
state.toggle:set(state.state)
|
state.toggle:set(state.state)
|
||||||
end
|
end
|
||||||
|
opts.on_close(win)
|
||||||
end),
|
end),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue