folke / zen-mode.nvim

🧘 Distraction-free coding for Neovim
Apache License 2.0
1.65k stars 45 forks source link

bug: when quiting all while in zenmode kitty / tmux changes aren't reverted. #111

Closed AnthonyPoschen closed 1 month ago

AnthonyPoschen commented 8 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.4 Build type: Release LuaJIT 2.1.1700008891

Operating system/version

MacOs 14.2.1

Describe the bug

while using tmux and kitty terminal plugins while in zen mode with increased font size and tmux status's hidden if you directly close vim the font and tmux settings are not reverted back.

To get around the issue i made a autocommand based on reading the source code here. It appears the revert also needs to be fired on VimLeave or VimLeavePre to avoid this issue occuring.

The autocmd workaround is the following

vim.api.nvim_create_autocmd({ "VimLeave", "VimLeavePre" }, {
    callback = function(ev, opts)
        os.execute("kitty @ --to $KITTY_LISTEN_ON set-font-size '0'")
        os.execute("tmux set status 2")
        os.execute("tmux list-panes -F '\\#F' | grep -q Z && tmux resize-pane -Z")
    end,
})

Steps To Reproduce

  1. open file
  2. while in normal mode enter :Zenmode
  3. while in normal mode enter :wqa<CR>

Expected Behavior

i expect the font to return to the original size and the tmux status lines to return.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    {
        "folke/zen-mode.nvim",
        opts = {
            window = {
                backdrop = 1, -- shade the backdrop of the zen window. set to 1 to keep the same as normal
                width = 120, -- width of the zen window
                height = 1, -- height of the zen window
            },
            plugins = {
                options = {
                    enabled = true,
                    ruler = false, -- disables the ruler text in the cmd line area
                    showcmd = false, -- disables the command in the last line of the screen
                    laststatus = 0, -- turn off the statusline in zen mode
                },
                twilight = { enabled = true }, -- enable to start twilight when zen mode opens
                gitsigns = { enabled = false }, -- disables git signs
                tmux = { enabled = true }, -- disables the tmux statusline
                kitty = {
                    enabled = true,
                    font = "+4", -- font size increment
                },
            }, -- callback where you can add custom code when the zen window opens
        },
    },
    -- add any other plugins here
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
oitan commented 2 months ago

had the same issue, you workaround helped me. Thanks, @AnthonyPoschen !

b0ae989c commented 2 months ago

This is more of a misuse than a bug. A general workaround is

vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
  callback = function() require('zen-mode').close() end,
})
github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stalled for 7 days with no activity.