Skip to content
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

Detect and respond to terminal theme mode (light/dark) updates #12362

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

the-mikedavis
Copy link
Member

recording.mov

Closes #8899, #10281

Historically we haven't wanted to add this because querying OS theme preference required bringing in a bunch of platform-specific deps. A relatively recent VT extension originally proposed by the Contour terminal emulator though lets us query for the terminal's theme mode and receive updates when that changes. This can all be covered cleanly in crossterm with no extra deps. That extension seems to be gaining some steam with Ghostty and Kitty now supporting it on the terminal emulator side and neovim on the client side.

Theme config accepts an optional, extended form (like in #12098):

# this is still accepted:
# theme = "ayu_dark"
theme = { dark = "ayu_dark", light = "ayu_light" }

On startup we query the current theme mode and subscribe to future changes, swapping when we receive an update.

On the terminal emulator side this needs a bit of setup. The latest Kitty version (v0.38.1) supports this but you also need to follow https://sw.kovidgoyal.net/kitty/kittens/themes/#change-color-themes-automatically-when-the-os-switches-between-light-and-dark

This PR needs changes upstream in crossterm - I have a branch https://github.com/the-mikedavis/crossterm/tree/md/theme-mode that I will turn into a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically select light/dark theme variant
1 participant