[FEATURE] Add configurable syntax tokens for XML/HTML tag highlighting (#6130) #3844

Open
opened 2026-02-16 17:41:40 -05:00 by yindo · 5 comments
Owner

Originally created by @CasualDeveloper on GitHub (Dec 24, 2025).

Originally assigned to: @thdxr on GitHub.

Problem

XML/HTML tags are styled using hardcoded color mappings in getSyntaxRules():

{ scope: ["tag"], style: { foreground: theme.error } },
{ scope: ["tag.attribute"], style: { foreground: theme.syntaxKeyword } },
{ scope: ["tag.delimiter"], style: { foreground: theme.syntaxOperator } },

This means custom themes cannot independently control tag colors—they inherit from unrelated tokens (error, syntaxKeyword, syntaxOperator).

Proposed Solution

Add three new optional theme tokens:

  • syntaxTag - for tag names (<div>, <span>)
  • syntaxAttribute - for attributes (class=, href=)
  • syntaxTagDelimiter - for delimiters (<, >, />)

These would be optional with backward-compatible fallbacks to the current hardcoded values.

Files to Modify

  • packages/opencode/src/cli/cmd/tui/context/theme.tsx
  • packages/opencode/src/cli/cmd/tui/context/theme-resolver.ts
  • packages/opencode/test/cli/tui/theme.test.ts
  • packages/web/public/theme.json (schema)
  • packages/opencode/src/cli/cmd/tui/context/theme/opencode.json

Implementation Notes

  • Moved theme resolution logic into theme-resolver.ts for testability.
  • Added unit tests for fallback behavior and explicit overrides.

Status

PR open: #6130

Notes

  • AI Assistance: OpenCode + openai/gpt-5.2-codex (high)
Originally created by @CasualDeveloper on GitHub (Dec 24, 2025). Originally assigned to: @thdxr on GitHub. ## Problem XML/HTML tags are styled using hardcoded color mappings in `getSyntaxRules()`: ```typescript { scope: ["tag"], style: { foreground: theme.error } }, { scope: ["tag.attribute"], style: { foreground: theme.syntaxKeyword } }, { scope: ["tag.delimiter"], style: { foreground: theme.syntaxOperator } }, ``` This means custom themes cannot independently control tag colors—they inherit from unrelated tokens (`error`, `syntaxKeyword`, `syntaxOperator`). ## Proposed Solution Add three new optional theme tokens: - `syntaxTag` - for tag names (`<div>`, `<span>`) - `syntaxAttribute` - for attributes (`class=`, `href=`) - `syntaxTagDelimiter` - for delimiters (`<`, `>`, `/>`) These would be optional with backward-compatible fallbacks to the current hardcoded values. ## Files to Modify - `packages/opencode/src/cli/cmd/tui/context/theme.tsx` - `packages/opencode/src/cli/cmd/tui/context/theme-resolver.ts` - `packages/opencode/test/cli/tui/theme.test.ts` - `packages/web/public/theme.json` (schema) - `packages/opencode/src/cli/cmd/tui/context/theme/opencode.json` ## Implementation Notes - Moved theme resolution logic into `theme-resolver.ts` for testability. - Added unit tests for fallback behavior and explicit overrides. ## Status PR open: #6130 ## Notes - **AI Assistance**: OpenCode + openai/gpt-5.2-codex (high)
yindo added the opentui label 2026-02-16 17:41:40 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 24, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #5088: Theming: Unable to change text input placeholder color (same pattern of missing dedicated theme tokens)
  • #5286: Separate theming of sidebar background color (extends theme customization requests)
  • #815: Hot reload or add keymap to reload the theme (would complement theme token additions)
  • #2750: Improve UI customization / accessibility (broader theming/customization request)

These issues share the common theme of requesting more granular control over theming and syntax highlighting in OpenCode. Feel free to ignore if your specific case requires something different!

@github-actions[bot] commented on GitHub (Dec 24, 2025): This issue might be a duplicate of existing issues. Please check: - #5088: Theming: Unable to change text input placeholder color (same pattern of missing dedicated theme tokens) - #5286: Separate theming of sidebar background color (extends theme customization requests) - #815: Hot reload or add keymap to reload the theme (would complement theme token additions) - #2750: Improve UI customization / accessibility (broader theming/customization request) These issues share the common theme of requesting more granular control over theming and syntax highlighting in OpenCode. Feel free to ignore if your specific case requires something different!
Author
Owner

@CasualDeveloper commented on GitHub (Dec 24, 2025):

Reviewed the related issues flagged by the bot - this is not a duplicate.

  • #5088 - Same pattern (missing theme token) but for placeholder text, not syntax highlighting
  • #5286 - Requests separate sidebar background token, different scope
  • #815 - About hot-reloading themes, unrelated
  • #2750 - Broader accessibility/UI customization, different scope

This issue specifically addresses syntax highlighting tokens for XML/HTML tags.

@CasualDeveloper commented on GitHub (Dec 24, 2025): Reviewed the related issues flagged by the bot - this is not a duplicate. - **#5088** - Same pattern (missing theme token) but for placeholder text, not syntax highlighting - **#5286** - Requests separate sidebar background token, different scope - **#815** - About hot-reloading themes, unrelated - **#2750** - Broader accessibility/UI customization, different scope This issue specifically addresses syntax highlighting tokens for XML/HTML tags.
Author
Owner

@CasualDeveloper commented on GitHub (Dec 24, 2025):

I have a working implementation ready - typechecks pass.

@CasualDeveloper commented on GitHub (Dec 24, 2025): I have a working implementation ready - typechecks pass.
Author
Owner

@CasualDeveloper commented on GitHub (Dec 24, 2025):

Re-committed with valid GPG signature. PR ready: #6130

Will continue rebasing on top of release tags as they're set.

@CasualDeveloper commented on GitHub (Dec 24, 2025): Re-committed with valid GPG signature. PR ready: #6130 Will continue rebasing on top of release tags as they're set.
Author
Owner

@CasualDeveloper commented on GitHub (Dec 30, 2025):

Will continue rebasing on top of release tags as they're set.

@CasualDeveloper commented on GitHub (Dec 30, 2025): Will continue rebasing on top of release tags as they're set.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3844