fix(toggle): un-maximize when quiting Neovim

This commit is contained in:
Folke Lemaitre 2024-06-05 07:02:16 +02:00
parent 90e68edfe7
commit 1c583650e6
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -73,8 +73,13 @@ function M.inlay_hints(buf, value)
end end
end end
---@type {width:number, height:number}?
M._maximized = nil M._maximized = nil
function M.maximize() ---@param state boolean?
function M.maximize(state)
if state == (M._maximized ~= nil) then
return
end
if M._maximized then if M._maximized then
vim.o.winwidth = M._maximized.width vim.o.winwidth = M._maximized.width
vim.o.winheight = M._maximized.height vim.o.winheight = M._maximized.height
@ -95,8 +100,7 @@ function M.maximize()
group = vim.api.nvim_create_augroup("lazyvim_restore_max_exit_pre", { clear = true }), group = vim.api.nvim_create_augroup("lazyvim_restore_max_exit_pre", { clear = true }),
desc = "Restore width/height when close Neovim while maximized", desc = "Restore width/height when close Neovim while maximized",
callback = function() callback = function()
vim.o.winwidth = M._maximized.width M.maximize(false)
vim.o.winheight = M._maximized.height
end, end,
}) })
end end