Skip to content

opencode: fix theme polarity for light base16 schemes#2192

Open
Programmerino wants to merge 1 commit intonix-community:masterfrom
Programmerino:fix/opencode-light-polarity
Open

opencode: fix theme polarity for light base16 schemes#2192
Programmerino wants to merge 1 commit intonix-community:masterfrom
Programmerino:fix/opencode-light-polarity

Conversation

@Programmerino
Copy link
Copy Markdown

@Programmerino Programmerino commented Feb 8, 2026

Problem

OpenCode themes have separate dark and light color variants, selected at runtime based on terminal background detection (OSC 11). The existing mapping always assigns base00 to the dark variant and base06 to light.

For dark-polarity schemes (base00 = dark background), this is correct. For light-polarity schemes (e.g. base00 = #ffffff), the assignments are inverted: when the terminal correctly reports light mode, OpenCode uses the light variant which contains the dark colors, and vice versa.

The result is that light scheme users always see wrong colors regardless of terminal detection.

Fix

Add polarity to the config function arguments and swap dark/light assignments when polarity == "light". This follows the same pattern used by other modules (e.g. fnott, fuzzel, glance).

A mkColor helper replaces the verbose inline attrsets, which also makes the module more readable and ~40% shorter.

No behavioral change for dark-polarity schemes (the default code path is identical).

@stylix-automation stylix-automation bot added topic: home-manager Home Manager target topic: modules /modules/ subsystem labels Feb 8, 2026
@stylix-automation stylix-automation bot requested a review from arunoruto February 8, 2026 05:17
OpenCode themes have separate "dark" and "light" color variants,
used when the terminal reports dark or light mode respectively.

The existing mapping always assigns base00 to the "dark" variant and
base06 to "light". This is correct for dark-polarity base16 schemes
(where base00 is a dark background), but inverted for light-polarity
schemes (where base00 is a light background like #ffffff). The result
is that light scheme users get dark colors when their terminal correctly
reports light mode.

Fix this by adding the polarity argument and swapping dark/light
assignments when polarity is "light". No behavioral change for dark
schemes.

Also cleans up stray blank lines around syntaxKeyword and replaces
verbose inline attrsets with a mkColor helper for readability.
@Programmerino Programmerino force-pushed the fix/opencode-light-polarity branch from 0a00b63 to 78b45a7 Compare February 8, 2026 05:21
Copy link
Copy Markdown
Member

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description must at least contain the mandatory checkbox from the PR template for us to potentially merge this code.

Also, CI is failing.

OpenCode themes have separate dark and light color variants, selected at runtime based on terminal background detection (OSC 11).

IIUC, if OpenCode follows the terminal polarity, why do we need to override the OpenCode polarity when the terminal should already respect this?

Could you provide screenshots for the {before,after} * {dark,light} matrix of this PR?

@Juanal07
Copy link
Copy Markdown

Juanal07 commented Mar 27, 2026

in my case looks like this with stylix light mode catppuccin theme, looks wrong like the OP said the background should be white
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: home-manager Home Manager target topic: modules /modules/ subsystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants