Closed mikesmithgh closed 9 months ago
There is currently no way to set overrides for dark and light backgrounds independently. Seems like it's a missing crucial functionality.
Any updates on this? It's pretty annoying when users switches between dark and light mode and it happens to be everyday.
That is not a use case I have ever considered: how do you use background switching as part of your workflow?
We can add an option to disable listening for &background
changes.
@alex-courtis Hi thanks for your reply.
how do you use background switching as part of your workflow?
I use tmux to for project management, ususally I keep several neovim instances in different tmux sessions for days or even weeks without closing them as long as I am still working on that project.
My desktop switches between light and dark mode automatically according to the time and my neovim is configured to follow these changes, so every time the background changes all my custom icons and colors are lost. To get those back the only way is to restart neovim, which is cumbersome when you have over five neovim instances in tmux sessions.
We can add an option to disable listening for &background changes.
If we disable changing icon colors for &background changes, I am afraid the icon color will look off in the new background, as mentioned here https://github.com/nvim-tree/nvim-web-devicons/issues/193
If we disable changing icon colors for &background changes, I am afraid the icon color will look off in the new background, as mentioned here #193
I agree with @Bekaboo, this seems like not the right approach. Perhaps we could store overrides in some variable that persists past the setup
function? Looks like global_opts
has an overrides
field that is never used, I think it would make sense to store user overrides here so they can be properly refreshed, perhaps somewhere here:
function M.refresh()
refresh_icons()
M.set_up_highlights(true)
-- refresh user overrides stored in global_opts.overrides
end
I understand, thank you for looking into this @Bekaboo @ribru17
Yes, persisting all setup overrides and applying during refresh
is necessary: override
, override_by_filename
and override_by_extension
Updating title.
In the meantime, you could call setup
yourself when you change &background, or create your own autocommand to do so, something like:
vim.api.nvim_create_autocmd("OptionSet", {
pattern = "background",
callback = my_web_devicons_setup,
})
When you
set background=light
the icon overrides are lost.See https://github.com/nvim-tree/nvim-web-devicons/blob/master/lua/nvim-web-devicons.lua#L1607
Demo:
https://github.com/nvim-tree/nvim-web-devicons/assets/10135646/73132ff3-7b74-4b46-9fbc-5a9ea54137eb
This doesn't seem likely to happen in a normal session so probably a low priority issue.