folke / zen-mode.nvim

🧘 Distraction-free coding for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

AnthonyPoschen opened this issue · comments

Did you check docs and existing issues?

  • I have read all the zen-mode.nvim docs
  • I have searched the existing issues of zen-mode.nvim
  • I have searched the existing issues of plugins related to this issue

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

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

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,
})

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.

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