Skip to content

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

@CasualDeveloper

Description

@CasualDeveloper

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)

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions