diff --git a/lua/zak/remap.lua b/lua/zak/remap.lua index 9fa122e..80f0478 100644 --- a/lua/zak/remap.lua +++ b/lua/zak/remap.lua @@ -143,21 +143,36 @@ vim.keymap.set('n', 'cd', function() vim.cmd('Ex ' .. config_dir) end, { desc = 'Jump to Neovim config directory' }) -vim.keymap.set('n', 'z', function() - require("zen-mode").toggle({ - window = { - width = .65, -- width will be 85% of the editor width - options = {} - }, - plugins = { - options = { - enabled = true, - ruler = true, -- disables the ruler text in the cmd line area - showcmd = true, -- disables the command in the last line of the screen - -- you may turn on/off statusline in zen mode by setting 'laststatus' - -- statusline will be shown only if 'laststatus' == 3 - laststatus = 3, - } - } - }) -end, { desc = 'Zen Mode' }) +vim.g.is_maximized = false +vim.g.original_height = 0 +vim.g.original_width = 0 + +function ToggleZen() + if vim.g.is_maximized then + -- Restore original size + if vim.g.original_height > 0 then vim.cmd('resize ' .. vim.g.original_height) end + if vim.g.original_width > 0 then vim.cmd('vertical resize ' .. vim.g.original_width) end + vim.g.is_maximized = false + else + -- Save current dimensions + vim.g.original_height = vim.fn.winheight(0) + vim.g.original_width = vim.fn.winwidth(0) + + -- Check if the buffer is a terminal + if vim.bo.buftype == "terminal" then + -- Maximize height only + vim.cmd('resize') + else + -- Maximize both height and width + vim.cmd('resize') + vim.cmd('vertical resize') + end + + vim.g.is_maximized = true + end +end + +vim.keymap.set('n', '', ToggleZen, { desc = 'Zen Mode' }) +vim.keymap.set('v', '', ToggleZen, { desc = 'Zen Mode' }) +vim.keymap.set('i', '', ToggleZen, { desc = 'Zen Mode' }) +vim.keymap.set('t', '', ToggleZen, { desc = 'Zen Mode', silent = true })