Closed miguno closed 1 year ago
Take a look at user vars; https://wezfurlong.org/wezterm/config/lua/window-events/user-var-changed.html is triggered when a user var is changed.
You could have your nvim integration set a user var named something like NVIM_ZEN_MODE
and then have some corresponding lua code set config overrides based on the value of the user var.
Thank you for the quick response and the useful pointers!
Here's how I was able to set this up with neovim 0.8.1 and wezterm 20221119-145034-49b9839f in case other users have a similar question.
wezterm configuration
wezterm.on('user-var-changed', function(window, pane, name, value)
-- Increase the line height of wezterm when we enter zen mode in neovim
if name == "NVIM_ZEN_MODE" then
local overrides = window:get_config_overrides() or {}
if value == "1" and not overrides.line_height then
overrides.line_height = 1.3
else
overrides.line_height = nil
end
window:set_config_overrides(overrides)
end
end)
return {
-- Terminal defaults
line_height = 1.0,
...
}
neovim configuration
-- Plugin configuration for https://github.com/folke/zen-mode.nvim
require("zen-mode").setup {
-- callback where you can add custom code when the Zen window opens
on_open = function(win)
-- Equivalent of
-- $ printf "\033]1337;SetUserVar=%s=%s\007" NVIM_ZEN_MODE `echo -n 1 | base64`
-- "MQ==" is `echo -n 1 | base64`.
vim.cmd([[call chansend(v:stderr, "\033]1337;SetUserVar=NVIM_ZEN_MODE=MQ==\007")]])
end,
-- callback where you can add custom code when the Zen window closes
on_close = function()
-- Equivalent of
-- $ printf "\033]1337;SetUserVar=%s=%s\007" NVIM_ZEN_MODE `echo -n 0 | base64`
-- "MA==" is `echo -n 0 | base64`.
vim.cmd([[call chansend(v:stderr, "\033]1337;SetUserVar=NVIM_ZEN_MODE=MA==\007")]])
end,
}
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
I am using neovim inside wezterm, and I am looking for a way to change the wezterm
line_height
depending on whether neovim has entered Zen mode for focused writing.I can change neovim-related settings when zen mode is entered, but was wondering whether there is an API or CLI feature that would allow me to also interact with wezterm from within neovim.