Detect and respond to terminal theme mode (light/dark) updates #12362
+161
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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):
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.