From ee730bdd91ea1ce21001f2fc470c182b92d9cd69 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Sat, 3 Oct 2026 21:43:07 -0700 Subject: [PATCH] refactor(tui): remove unused V1 syntax theme generation (#52987) --- packages/tui/src/theme/index.ts | 2 +- packages/tui/src/theme/v1.ts | 519 +------------------------------- 2 files changed, 2 insertions(+), 519 deletions(-) diff --git a/packages/tui/src/theme/index.ts b/packages/tui/src/theme/index.ts index 6e75be31336..b40f12c01ed 100644 --- a/packages/tui/src/theme/index.ts +++ b/packages/tui/src/theme/index.ts @@ -3,7 +3,7 @@ import { resolveThemeColors } from "./resolve" import { DEFAULT_THEMES, type Theme, type ThemeV1Json } from "./v1" import opencode from "./assets/v2/opencode.json" with { type: "json" } -export { DEFAULT_THEMES, generateSyntax, selectedForeground, type Theme, type ThemeV1Json } from "./v1" +export { DEFAULT_THEMES, type Theme, type ThemeV1Json } from "./v1" export type ThemeDocumentSource = Record diff --git a/packages/tui/src/theme/v1.ts b/packages/tui/src/theme/v1.ts index f9115caef5f..5f76c654cc7 100644 --- a/packages/tui/src/theme/v1.ts +++ b/packages/tui/src/theme/v1.ts @@ -1,5 +1,4 @@ -import { RGBA, SyntaxStyle } from "@opentui/core" -import type { Theme, ThemeV1Json } from "@opencode/theme/tui/v1" +import type { ThemeV1Json } from "@opencode/theme/tui/v1" import aura from "./assets/aura.json" with { type: "json" } import ayu from "./assets/ayu.json" with { type: "json" } import carbonfox from "./assets/carbonfox.json" with { type: "json" } @@ -69,519 +68,3 @@ export const DEFAULT_THEMES: Record = { zenburn, carbonfox, } - -export function selectedForeground(theme: Theme, bg?: RGBA): RGBA { - if (theme._hasSelectedListItemText) return theme.selectedListItemText - - if (theme.background.a === 0) { - const targetColor = bg ?? theme.primary - const { r, g, b } = targetColor - const luminance = 0.299 * r + 0.587 * g + 0.114 * b - return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255) - } - - return theme.background -} - -export function generateSyntax(theme: Theme) { - return SyntaxStyle.fromTheme(getSyntaxRules(theme)) -} - -function getSyntaxRules(theme: Theme) { - return [ - { - scope: ["default"], - style: { - foreground: theme.text, - }, - }, - { - scope: ["prompt"], - style: { - foreground: theme.accent, - }, - }, - { - scope: ["extmark.file"], - style: { - foreground: theme.warning, - bold: true, - }, - }, - { - scope: ["extmark.agent"], - style: { - foreground: theme.secondary, - bold: true, - }, - }, - { - scope: ["extmark.paste"], - style: { - foreground: selectedForeground(theme, theme.warning), - background: theme.warning, - bold: true, - }, - }, - { - scope: ["comment"], - style: { - foreground: theme.syntaxComment, - italic: true, - }, - }, - { - scope: ["comment.documentation"], - style: { - foreground: theme.syntaxComment, - italic: true, - }, - }, - { - scope: ["string", "symbol"], - style: { - foreground: theme.syntaxString, - }, - }, - { - scope: ["number", "boolean"], - style: { - foreground: theme.syntaxNumber, - }, - }, - { - scope: ["character.special"], - style: { - foreground: theme.syntaxString, - }, - }, - { - scope: ["keyword.return", "keyword.conditional", "keyword.repeat", "keyword.coroutine"], - style: { - foreground: theme.syntaxKeyword, - italic: true, - }, - }, - { - scope: ["keyword.type"], - style: { - foreground: theme.syntaxType, - bold: true, - italic: true, - }, - }, - { - scope: ["keyword.function", "function.method"], - style: { - foreground: theme.syntaxFunction, - }, - }, - { - scope: ["keyword"], - style: { - foreground: theme.syntaxKeyword, - italic: true, - }, - }, - { - scope: ["keyword.import"], - style: { - foreground: theme.syntaxKeyword, - }, - }, - { - scope: ["operator", "keyword.operator", "punctuation.delimiter"], - style: { - foreground: theme.syntaxOperator, - }, - }, - { - scope: ["keyword.conditional.ternary"], - style: { - foreground: theme.syntaxOperator, - }, - }, - { - scope: ["variable", "variable.parameter", "function.method.call", "function.call"], - style: { - foreground: theme.syntaxVariable, - }, - }, - { - scope: ["variable.member", "function", "constructor"], - style: { - foreground: theme.syntaxFunction, - }, - }, - { - scope: ["type", "module"], - style: { - foreground: theme.syntaxType, - }, - }, - { - scope: ["constant"], - style: { - foreground: theme.syntaxNumber, - }, - }, - { - scope: ["property"], - style: { - foreground: theme.syntaxVariable, - }, - }, - { - scope: ["class"], - style: { - foreground: theme.syntaxType, - }, - }, - { - scope: ["parameter"], - style: { - foreground: theme.syntaxVariable, - }, - }, - { - scope: ["punctuation", "punctuation.bracket"], - style: { - foreground: theme.syntaxPunctuation, - }, - }, - { - scope: ["variable.builtin", "type.builtin", "function.builtin", "module.builtin", "constant.builtin"], - style: { - foreground: theme.error, - }, - }, - { - scope: ["variable.super"], - style: { - foreground: theme.error, - }, - }, - { - scope: ["string.escape", "string.regexp"], - style: { - foreground: theme.syntaxKeyword, - }, - }, - { - scope: ["keyword.directive"], - style: { - foreground: theme.syntaxKeyword, - italic: true, - }, - }, - { - scope: ["punctuation.special"], - style: { - foreground: theme.syntaxOperator, - }, - }, - { - scope: ["keyword.modifier"], - style: { - foreground: theme.syntaxKeyword, - italic: true, - }, - }, - { - scope: ["keyword.exception"], - style: { - foreground: theme.syntaxKeyword, - italic: true, - }, - }, - // Markdown specific styles - { - scope: ["markup.heading"], - style: { - foreground: theme.markdownHeading, - bold: true, - }, - }, - { - scope: ["markup.heading.1"], - style: { - foreground: theme.markdownHeading, - bold: true, - underline: true, - }, - }, - { - scope: ["markup.heading.2"], - style: { - foreground: theme.markdownHeading, - bold: true, - }, - }, - { - scope: ["markup.heading.3"], - style: { - foreground: theme.markdownHeading, - bold: true, - }, - }, - { - scope: ["markup.heading.4"], - style: { - foreground: theme.markdownHeading, - bold: true, - }, - }, - { - scope: ["markup.heading.5"], - style: { - foreground: theme.markdownHeading, - bold: true, - }, - }, - { - scope: ["markup.heading.6"], - style: { - foreground: theme.markdownHeading, - bold: true, - }, - }, - { - scope: ["markup.bold", "markup.strong"], - style: { - foreground: theme.markdownStrong, - bold: true, - }, - }, - { - scope: ["markup.italic"], - style: { - foreground: theme.markdownEmph, - italic: true, - }, - }, - { - scope: ["markup.list"], - style: { - foreground: theme.markdownListItem, - }, - }, - { - scope: ["markup.quote"], - style: { - foreground: theme.markdownBlockQuote, - italic: true, - }, - }, - { - scope: ["markup.raw", "markup.raw.block"], - style: { - foreground: theme.markdownCode, - }, - }, - { - scope: ["markup.raw.inline"], - style: { - foreground: theme.markdownCode, - background: theme.background, - }, - }, - { - scope: ["markup.link"], - style: { - foreground: theme.markdownLink, - underline: true, - }, - }, - { - scope: ["markup.link.label"], - style: { - foreground: theme.markdownLinkText, - underline: true, - }, - }, - { - scope: ["markup.link.url"], - style: { - foreground: theme.markdownLink, - underline: true, - }, - }, - { - scope: ["label"], - style: { - foreground: theme.markdownLinkText, - }, - }, - { - scope: ["spell", "nospell"], - style: { - foreground: theme.text, - }, - }, - // Additional common highlight groups - { - scope: ["string.special", "string.special.url"], - style: { - foreground: theme.markdownLink, - underline: true, - }, - }, - { - scope: ["character"], - style: { - foreground: theme.syntaxString, - }, - }, - { - scope: ["float"], - style: { - foreground: theme.syntaxNumber, - }, - }, - { - scope: ["comment.error"], - style: { - foreground: theme.error, - italic: true, - bold: true, - }, - }, - { - scope: ["comment.warning"], - style: { - foreground: theme.warning, - italic: true, - bold: true, - }, - }, - { - scope: ["comment.todo", "comment.note"], - style: { - foreground: theme.info, - italic: true, - bold: true, - }, - }, - { - scope: ["namespace"], - style: { - foreground: theme.syntaxType, - }, - }, - { - scope: ["field"], - style: { - foreground: theme.syntaxVariable, - }, - }, - { - scope: ["type.definition"], - style: { - foreground: theme.syntaxType, - bold: true, - }, - }, - { - scope: ["keyword.export"], - style: { - foreground: theme.syntaxKeyword, - }, - }, - { - scope: ["attribute", "annotation"], - style: { - foreground: theme.warning, - }, - }, - { - scope: ["tag"], - style: { - foreground: theme.error, - }, - }, - { - scope: ["tag.attribute"], - style: { - foreground: theme.syntaxKeyword, - }, - }, - { - scope: ["tag.delimiter"], - style: { - foreground: theme.syntaxOperator, - }, - }, - { - scope: ["markup.strikethrough"], - style: { - foreground: theme.textMuted, - }, - }, - { - scope: ["markup.underline"], - style: { - foreground: theme.text, - underline: true, - }, - }, - { - scope: ["markup.list.checked"], - style: { - foreground: theme.success, - }, - }, - { - scope: ["markup.list.unchecked"], - style: { - foreground: theme.textMuted, - }, - }, - { - scope: ["diff.plus"], - style: { - foreground: theme.diffAdded, - background: theme.diffAddedBg, - }, - }, - { - scope: ["diff.minus"], - style: { - foreground: theme.diffRemoved, - background: theme.diffRemovedBg, - }, - }, - { - scope: ["diff.delta"], - style: { - foreground: theme.diffContext, - background: theme.diffContextBg, - }, - }, - { - scope: ["error"], - style: { - foreground: theme.error, - bold: true, - }, - }, - { - scope: ["warning"], - style: { - foreground: theme.warning, - bold: true, - }, - }, - { - scope: ["info"], - style: { - foreground: theme.info, - }, - }, - { - scope: ["debug"], - style: { - foreground: theme.textMuted, - }, - }, - ] -}