Allow gvim to follow the system dark mode and allow the user to override this choice.
The option is already being honored by the GTK UI when 'guioptions' cointains 'd', but this new option gives more freedom to implement different strategies (e.g. the use_bg
one that follows the 'bg' value) as needed.
Closes #3922
cc @ychin as we had discussed the 'guidarkmode'
behaviour quite some time ago.
https://github.com/vim/vim/pull/18029
(15 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@LemonBoy pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.
Your contribution is great, how about add my commit in it?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Your contribution is great, how about add my commit in it?
Sure, why not, it looks pretty cool. You can enable it with guidarkmode=use_theme
, the popup menus are currently styled using the light theme because I couldn't be arsed to implement a way to check if the GUI colors are bright or dark.
Anyways, any improvement is welcome.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@chrisbra commented on this pull request.
> @@ -4333,6 +4333,20 @@ A jump table for the options with a short description can be found at |Q_op|. In its simplest form the value is just one font name. See |gui-font| for the details. + *'guidarkmode'* +'guidarkmode' string (default "automatic") + global + {only available when compiled with GUI enabled} + This option specifies whether Vim GUI elements should be drawn using a + dark color scheme if available.
color scheme has a very distinct meaning in Vim. Is this really a Vim color scheme or something else?
> @@ -4333,6 +4333,20 @@ A jump table for the options with a short description can be found at |Q_op|. In its simplest form the value is just one font name. See |gui-font| for the details. + *'guidarkmode'* +'guidarkmode' string (default "automatic") + global + {only available when compiled with GUI enabled} + This option specifies whether Vim GUI elements should be drawn using a + dark color scheme if available. + The allowed values are: + automatic Follow the current system's preference. + prefer_dark Apply the dark mode to the GUI elements. + prefer_light Apply the light mode to the GUI elements.
I don't understand that. Does prefer_dark mean, to use dark GUI mode? And prefer_light means to use light/default GUI mode?
> @@ -4333,6 +4333,20 @@ A jump table for the options with a short description can be found at |Q_op|. In its simplest form the value is just one font name. See |gui-font| for the details. + *'guidarkmode'* +'guidarkmode' string (default "automatic") + global + {only available when compiled with GUI enabled} + This option specifies whether Vim GUI elements should be drawn using a + dark color scheme if available. + The allowed values are: + automatic Follow the current system's preference.
How is this different to go-d
? Which one is preferred? This should also probably be linked here.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
By the way, is it really need to have too many options?
I think we only need two options, one is follow the background option, one is follow the colorscheme.
TODO: Now the autocomplete of the options is still a vacancy.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
I compile the forks it seems that automatic isn't take effect at first
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Or maybe we can separate implement in windows 11 and before. And use guioptions to control whether change the colour of titlebar or not. We change the colour of titlebar with the colour of background. set these logic in gui_mch_new_colors() function.
At present, Vim's default colorscheme doesn't support set background = dark. So it's no use to set according to the OS's setting.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@LemonBoy commented on this pull request.
> @@ -4333,6 +4333,20 @@ A jump table for the options with a short description can be found at |Q_op|. In its simplest form the value is just one font name. See |gui-font| for the details. + *'guidarkmode'* +'guidarkmode' string (default "automatic") + global + {only available when compiled with GUI enabled} + This option specifies whether Vim GUI elements should be drawn using a + dark color scheme if available.
Nope, it's just the system dark color palette/implementation/whatever.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
> @@ -4333,6 +4333,20 @@ A jump table for the options with a short description can be found at |Q_op|. In its simplest form the value is just one font name. See |gui-font| for the details. + *'guidarkmode'* +'guidarkmode' string (default "automatic") + global + {only available when compiled with GUI enabled} + This option specifies whether Vim GUI elements should be drawn using a + dark color scheme if available. + The allowed values are: + automatic Follow the current system's preference. + prefer_dark Apply the dark mode to the GUI elements. + prefer_light Apply the light mode to the GUI elements.
Yep.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@LemonBoy commented on this pull request.
> @@ -4333,6 +4333,20 @@ A jump table for the options with a short description can be found at |Q_op|. In its simplest form the value is just one font name. See |gui-font| for the details. + *'guidarkmode'* +'guidarkmode' string (default "automatic") + global + {only available when compiled with GUI enabled} + This option specifies whether Vim GUI elements should be drawn using a + dark color scheme if available. + The allowed values are: + automatic Follow the current system's preference.
go-d
was too limited as it was just a on/off switch, adding this setting allows for more combinations without being limited to one letter options.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
By the way, is it really need to have too many options? I think we only need two options, one is follow the background option, one is follow the colorscheme.
Adding a way to force the dark or light mode doesn't really add a lot of code.
So it's no use to set according to the OS's setting.
That's what the automatic
switch is supposed to do, follow the system preferences.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
I compile the pr's version. It seems that guidarkmode isn't work unless I reset the option manually or put it in vimrc
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Alright, it took me a while to remember what I did two years ago. The default is to keep the titlebar as-is, following the go-d
option if present.
Regarding docs, please feel free to improve it as needed, I'm running out of bandwidth to take care of this PR.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Can't we not just fix the go-d
case, without adding a new option?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Can't we not just fix the
go-d
case, without adding a new option?
This was already discussed in #12282, the plan was to have something more flexible and eventually something that's compatible with what MacVIM already has.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Ah, I remember thanks. Let me try it out to see how well this works. @ychin any comments from your side? Would you be fine with the suggested changes?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@chrisbra commented on this pull request.
In src/optiondefs.h:
> @@ -1228,6 +1228,15 @@ static struct vimoption options[] = #else (char_u *)NULL, PV_NONE, NULL, NULL, {(char_u *)NULL, (char_u *)0L} +#endif + SCTX_INIT}, + {"guidarkmode", NULL, P_STRING|P_VI_DEF|P_RCLR, +#if defined(FEAT_GUI_DARKTHEME) + (char_u *)&p_guidarkmode, PV_NONE, did_set_guidarkmode, NULL, + {(char_u *)"", (char_u *)0L}
I thought the default is supposed to be automatic?
In src/optiondefs.h:
> @@ -1228,6 +1228,15 @@ static struct vimoption options[] = #else (char_u *)NULL, PV_NONE, NULL, NULL, {(char_u *)NULL, (char_u *)0L} +#endif + SCTX_INIT}, + {"guidarkmode", NULL, P_STRING|P_VI_DEF|P_RCLR, +#if defined(FEAT_GUI_DARKTHEME) + (char_u *)&p_guidarkmode, PV_NONE, did_set_guidarkmode, NULL,
No tab completions of option values?
> @@ -4333,6 +4333,20 @@ A jump table for the options with a short description can be found at |Q_op|. In its simplest form the value is just one font name. See |gui-font| for the details. + *'guidarkmode'* +'guidarkmode' string (default "automatic") + global + {only available when compiled with GUI enabled} + This option specifies whether Vim GUI elements should be drawn using a + dark color scheme if available. + The allowed values are: + automatic Follow the current system's preference. + prefer_dark Apply the dark mode to the GUI elements. + prefer_light Apply the light mode to the GUI elements. + use_bg Follow the value of Vim's |background| option. + use_theme Use the theme foreground and background colors to style the + titlebar.
So I tried it out. Automatic is nice, although this is not the default, as what is claimed. Also we cannot tab complete the available options. But it seems to be only applied to the title bar? The menu bar and the toolbar seem to stay in light mode.
Then I don't know what prefer_dark and prefer_light are supposed to be doing. Both options don't seem to make a difference at all, similar with use_theme
.
Then I was wondering, does it make sense to combine those values? Perhaps I want to switch dark mode automatic on but also want to set/unset it when issuing :set bg
?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@LemonBoy commented on this pull request.
In src/optiondefs.h:
> @@ -1228,6 +1228,15 @@ static struct vimoption options[] = #else (char_u *)NULL, PV_NONE, NULL, NULL, {(char_u *)NULL, (char_u *)0L} +#endif + SCTX_INIT}, + {"guidarkmode", NULL, P_STRING|P_VI_DEF|P_RCLR, +#if defined(FEAT_GUI_DARKTHEME) + (char_u *)&p_guidarkmode, PV_NONE, did_set_guidarkmode, NULL, + {(char_u *)"", (char_u *)0L}
Eh. It's a bit of a mess right now, if nothing is specified here we follow the d
spec in guioptions
, that's why I kept the empty string as default.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@LemonBoy commented on this pull request.
In src/optiondefs.h:
> @@ -1228,6 +1228,15 @@ static struct vimoption options[] = #else (char_u *)NULL, PV_NONE, NULL, NULL, {(char_u *)NULL, (char_u *)0L} +#endif + SCTX_INIT}, + {"guidarkmode", NULL, P_STRING|P_VI_DEF|P_RCLR, +#if defined(FEAT_GUI_DARKTHEME) + (char_u *)&p_guidarkmode, PV_NONE, did_set_guidarkmode, NULL,
Good catch, will fix that.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@LemonBoy commented on this pull request.
> @@ -4333,6 +4333,20 @@ A jump table for the options with a short description can be found at |Q_op|. In its simplest form the value is just one font name. See |gui-font| for the details. + *'guidarkmode'* +'guidarkmode' string (default "automatic") + global + {only available when compiled with GUI enabled} + This option specifies whether Vim GUI elements should be drawn using a + dark color scheme if available. + The allowed values are: + automatic Follow the current system's preference. + prefer_dark Apply the dark mode to the GUI elements. + prefer_light Apply the light mode to the GUI elements. + use_bg Follow the value of Vim's |background| option. + use_theme Use the theme foreground and background colors to style the + titlebar.
But it seems to be only applied to the title bar? The menu bar and the toolbar seem to stay in light mode.
Windows is to blame here, there's a way to get the toolbar and menubars to match the dark color but they're quite messy and require calling some undocumented DLL exports.
Then I don't know what prefer_dark and prefer_light are supposed to be doing. Both options don't seem to make a difference at all, similar with use_theme .
The prefer_
options force the bars to be in dark or light mode, independent of the system's configuration. use_theme
makes the bar background and forground color match the guibg
and guifg
of the Normal
group, while use_bg
applies the dark or light mode according to whether the bg
option is dark
or light
.
Suggestions to improve the docs (and/or the option names) are welcome.
Then I was wondering, does it make sense to combine those values? Perhaps I want to switch dark mode automatic on but also want to set/unset it when issuing :set bg ?
I'd avoid overcomplicating this mechanism heh
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
Closed #18029.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Well fuck me then, instead of discussing how to land this patch y'all merged (and reverted in record time) the half-assed version instead.
I have no time to deal with this bullshit,
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.