helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.36k stars 2.47k forks source link

Automatically select light/dark theme variant #8899

Open MaxVerevkin opened 10 months ago

MaxVerevkin commented 10 months ago

Query the terminal background color and choose a dark or light variant of a theme accordingly. This would be very convenient for people who switch between light/dark terminal themes.

archseer commented 10 months ago

Duplicate of https://github.com/helix-editor/helix/issues/2158

archseer commented 10 months ago

Well ok technically not quite the same, I'll leave it open for opinions

the-mikedavis commented 10 months ago

This is probably simpler/smaller to add than #2158 (we can query the host terminal for the current background color, right?) but would be less powerful - there wouldn't be any automatic switching when the OS switches between day/night unless we were constantly polling. We could check again on config reload (so you would script something to send all Helix instances the USR1 signal when the OS switches) but if you're doing that then it isn't much more complicated to also swap configs in the external script between light and dark themes. IMO it is still better to accomplish this outside of Helix.

MaxVerevkin commented 10 months ago

we can query the host terminal for the current background color, right?

Yes, neovim does that.

swap configs in the external script

I do this with kitty, but only because I can include config files from my main configuration. Keeping two copies of the same config is not ideal.

kirawi commented 10 months ago

What some people do instead is have theme = "theme.toml and then just swap the files (rather than editing the config) for the theme they want to use, and then reload the config.