New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration option to set theme to light/dark/auto #1917
Conversation
I've got the tests to pass, the I have a stylistic question: would it be better to rewrite the pattern matching like so? https://gist.github.com/mgax/0506394f61f5d47f856803cc52213a7a I'm guessing it's nice to have fewer calls to |
The first hunk looks better to me, I think I'd even split up the matching part and actually setting the background by storing the match result first, shadowing - match theme {
- Theme::Light => set_background("light"),
- Theme::Dark => set_background("dark"),
- };
+ let theme = match theme {
+ Theme::Light => "light",
+ Theme::Dark => "dark",
+ };
+ set_background(theme); The second hunk however looks too convoluted to me. I need to backtrack in order to see what braces will actually trigger the background change. Sidenote: Whatever you end up with, do run rustfmt afterwards, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I'm not too sure if passing the argument on the command line is really the way to go, since it could also be desired to be configurable with the casual g:neovide_*
variable mechanism. But I don't feel strongly about that either way.
Indeed, the CI failure is not your fault, it also happens locally for me, also on |
Co-authored-by: multisn8 <contact@multisamplednight.com>
Co-authored-by: multisn8 <contact@multisamplednight.com>
Hmm, I see what you mean. I wasn't aware of the
Yep sounds good. I've used Thanks for reviewing and for the suggestions! Let me know if I should switch to a |
Fwiw, I don't have any kind of permissions or right to go beyond technical reasons when discussing about implementing something one way or the other. Ideally there could also be anyone else in my place reviewing this. It just happens to be me in this moment, a random person not necessarily affiliated with Neovide. Other than that, yeah, for the sake of consistency and the variables being configurable from Neovim itself for custom mechanisms, the |
I'm sorry for having pressed you, and thanks for the clarification. I've updated the PR to use a setting. |
I'll take a final look over this in 22 hours or the like, not really in the right state of mind to hit the merge button. |
@mgax really cool feature, I just want to point out that some colorschemes doesnt support light themes or vice-versa. So isnt only about changing the background. In that case you have more components that could be a mess after updating the background as the Font color, Floaterm and Pmenu. for example one of the most famous colorscheme dracula hasnt support for light mode. So the user could choose a different one accordingly to the background. I think that this should be more customizable, as the same as auto-dark-mode.nvim which works really well but is available only for macos. but look the hook itself set_dark_mode = function()
vim.api.nvim_set_option('background', 'dark')
vim.cmd('colorscheme gruvbox')
end,
set_light_mode = function()
vim.api.nvim_set_option('background', 'light')
vim.cmd('colorscheme gruvbox')
end I think that something similar should be done here. |
And yet let's keep in mind that neovide is supposed to be fully compatible with neovim, not saying that this feature would bring incompatibility, but it's something to consider. As a neovim user I would like to have always as possible my neovim configs working out of any neovide feature (themes is one of them). |
to be really concise about it, I think the perfect solution would be a neovim config (lua) or plugin as auto-dark-mode.nvim but available for all platforms. |
Since the |
@falcucci that's interesting; I'm using catppuccin, which has support for both light and dark backgrounds, and flips between them automatically, but it makes sense that you may want more control. In that case @MultisampledNight's suggestion seems like the way to go. From a purity perspective, auto-dark-mode.nvim polls the system to keep the theme in sync, which is a bit wasteful. The editor already receives events from the system when the theme changes, in a cross-platform compatible way, so it feels natural to automatically update the equivalent option in neovim. |
@MultisampledNight mine would work just fine because I would ignore the the feature itself is nice, I am just wondering about which side put it, neovim or neovide. btw I'll test this PR to see if I get something. |
@mgax yeah but I think the polling is needed because who receives the event is the terminal (if not used within neovide), right? |
@falcucci the implementation changed, it's no longer a command-line option (
FWIW, it looks like winit supports the ThemeChanged event on MacOS, Windows and Web. Linux support is discussed here: rust-windowing/winit#1549 (comment). In any case, this patch doesn't change behaviour out of the box, it has to be enabled explicitly in the user's config. |
@mgax thank you for clarify it. I just tried out the feature and want to point out that maybe we should put a note in the docs about the The background will be correctly applied only if it has no besides it, I dont see any issue for now. |
Thank you! |
@MultisampledNight @falcucci thank you both! |
Fixes #1912. I've tested on MacOS and it works as intended.
For existing users, nothing changes; the user must explicitly set
the--theme
command-line option, theNEOVIDE_THEME
env var, or thetheme
option inconfig.toml
g:neovide_theme = 'auto'
to enable this new feature.