Skip to content

Commit e6e83f6

Browse files
authored
feat(plugins): implement Neovide plugin (#131)
Neovide is a commonly used GUI wrapper for Neovim, which may unfortunately be way too flashy and distracting at times; having a way to limit animations and have a convenient short-hand for integration logic feels like a nice improvement in line with what other external interfaces like ones for Wezterm and Kitty provide.
1 parent 9c34496 commit e6e83f6

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Distraction-free coding for Neovim >= 0.5
2121
- increase [Kitty](https://sw.kovidgoyal.net/kitty/) font-size
2222
- increase [Alacritty](https://alacritty.org/) font-size
2323
- increase [wezterm](https://wezfurlong.org/wezterm/) font-size
24+
- increase [Neovide](https://neovide.dev/) scale factor and disable animations
2425
- **Zen Mode** is automatically closed when a new non-floating window is opened
2526
- works well with plugins like [Telescope](https://github.com/nvim-telescope/telescope.nvim) to open a new buffer inside the Zen window
2627
- close the Zen window with `:ZenMode`, `:close` or `:quit`
@@ -113,6 +114,22 @@ Install the plugin with your preferred package manager:
113114
-- can be either an absolute font size or the number of incremental steps
114115
font = "+4", -- (10% increase per step)
115116
},
117+
-- this will change the scale factor in Neovide when in zen mode
118+
-- See alse also the Plugins/Wezterm section in this projects README
119+
neovide = {
120+
enabled = false,
121+
-- Will multiply the current scale factor by this number
122+
scale = 1.2
123+
-- disable the Neovide animations while in Zen mode
124+
disable_animations = {
125+
neovide_animation_length = 0,
126+
neovide_cursor_animate_command_line = false,
127+
neovide_scroll_animation_length = 0,
128+
neovide_position_animation_length = 0,
129+
neovide_cursor_animation_length = 0,
130+
neovide_cursor_vfx_mode = "",
131+
}
132+
},
116133
},
117134
-- callback where you can add custom code when the Zen window opens
118135
on_open = function(win)
@@ -178,6 +195,10 @@ set-option -g allow-passthrough on
178195

179196
See also: https://github.com/wez/wezterm/discussions/2550
180197

198+
### Neovide
199+
200+
Neovide config will only be executed if vim variable `g:neovide` is set to 1, which Neovide does automatically on startup. By modifying table `plugins.neovide.disable_animations`, you can control which variables in `g:` namespace get temporarily overriden while in Zen mode. By default, all animations are disabled. See [Neovide documentation](https://neovide.dev/configuration.html) for possible values.
201+
181202
## Inspiration
182203

183204
- Visual Studio Code [Zen Mode](https://code.visualstudio.com/docs/getstarted/userinterface#_zen-mode)

lua/zen-mode/config.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ local defaults = {
5858
-- can be either an absolute font size or the number of incremental steps
5959
font = "+4", -- (10% increase per step)
6060
},
61+
-- this will change the scale factor in Neovide when in zen mode
62+
-- See alse also the Plugins/Wezterm section in this projects README
63+
neovide = {
64+
enabled = false,
65+
-- Will multiply the current scale factor by this number
66+
scale = 1.2,
67+
-- disable the Neovide animations while in Zen mode
68+
disable_animations = {
69+
neovide_animation_length = 0,
70+
neovide_cursor_animate_command_line = false,
71+
neovide_scroll_animation_length = 0,
72+
neovide_position_animation_length = 0,
73+
neovide_cursor_animation_length = 0,
74+
neovide_cursor_vfx_mode = "",
75+
},
76+
},
6177
},
6278
-- callback where you can add custom code when the zen window opens
6379
on_open = function(_win) end,

lua/zen-mode/plugins.lua

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,33 @@ function M.tmux(state, disable, opts)
123123
end
124124
end
125125

126+
function M.neovide(state, disable, opts)
127+
if not vim.g.neovide then
128+
return
129+
end
130+
if disable then
131+
if opts.scale ~= 1 then
132+
state.scale = vim.g.neovide_scale_factor
133+
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * opts.scale
134+
end
135+
if opts.disable_animations then
136+
for key, value in pairs(opts.disable_animations) do
137+
state[key] = vim.g[key]
138+
vim.g[key] = value
139+
end
140+
end
141+
else
142+
if opts.scale ~= 1 then
143+
vim.g.neovide_scale_factor = state.scale
144+
end
145+
if opts.disable_animations then
146+
for key, _ in pairs(opts.disable_animations) do
147+
vim.g[key] = state[key]
148+
end
149+
end
150+
end
151+
end
152+
126153
function M.diagnostics(state, disable)
127154
if disable then
128155
vim.diagnostic.disable(0)

0 commit comments

Comments
 (0)