mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-17 12:56:41 +02:00
fix(tui): soften syntax colors for calls and builtins
This commit is contained in:
@@ -834,6 +834,12 @@ function getSyntaxRules(theme: Theme) {
|
||||
foreground: theme.syntaxFunction,
|
||||
},
|
||||
},
|
||||
{
|
||||
scope: ["function.call", "function.method.call", "function.builtin"],
|
||||
style: {
|
||||
foreground: theme.syntaxFunction,
|
||||
},
|
||||
},
|
||||
{
|
||||
scope: ["keyword"],
|
||||
style: {
|
||||
@@ -860,11 +866,17 @@ function getSyntaxRules(theme: Theme) {
|
||||
},
|
||||
},
|
||||
{
|
||||
scope: ["variable", "variable.parameter", "function.method.call", "function.call"],
|
||||
scope: ["variable"],
|
||||
style: {
|
||||
foreground: theme.syntaxVariable,
|
||||
},
|
||||
},
|
||||
{
|
||||
scope: ["variable.parameter", "variable.builtin", "module.builtin"],
|
||||
style: {
|
||||
foreground: theme.text,
|
||||
},
|
||||
},
|
||||
{
|
||||
scope: ["variable.member", "function", "constructor"],
|
||||
style: {
|
||||
@@ -908,15 +920,21 @@ function getSyntaxRules(theme: Theme) {
|
||||
},
|
||||
},
|
||||
{
|
||||
scope: ["variable.builtin", "type.builtin", "function.builtin", "module.builtin", "constant.builtin"],
|
||||
scope: ["type.builtin"],
|
||||
style: {
|
||||
foreground: theme.error,
|
||||
foreground: theme.syntaxType,
|
||||
},
|
||||
},
|
||||
{
|
||||
scope: ["constant.builtin"],
|
||||
style: {
|
||||
foreground: theme.syntaxNumber,
|
||||
},
|
||||
},
|
||||
{
|
||||
scope: ["variable.super"],
|
||||
style: {
|
||||
foreground: theme.error,
|
||||
foreground: theme.syntaxKeyword,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect, test } from "bun:test"
|
||||
|
||||
const { DEFAULT_THEMES, allThemes, addTheme, hasTheme, resolveTheme } = await import(
|
||||
const { DEFAULT_THEMES, allThemes, addTheme, generateSyntax, hasTheme, resolveTheme } = await import(
|
||||
"../../../src/cli/cmd/tui/context/theme"
|
||||
)
|
||||
|
||||
@@ -49,3 +49,17 @@ test("resolveTheme rejects circular color refs", () => {
|
||||
|
||||
expect(() => resolveTheme(item, "dark")).toThrow("Circular color reference")
|
||||
})
|
||||
|
||||
test("generateSyntax maps calls and builtins away from error red", () => {
|
||||
const theme = resolveTheme(DEFAULT_THEMES.opencode, "dark")
|
||||
const syntax = generateSyntax(theme)
|
||||
|
||||
try {
|
||||
expect(syntax.getStyle("function.call")?.fg?.equals(theme.syntaxFunction)).toBe(true)
|
||||
expect(syntax.getStyle("function.builtin")?.fg?.equals(theme.syntaxFunction)).toBe(true)
|
||||
expect(syntax.getStyle("variable.parameter")?.fg?.equals(theme.text)).toBe(true)
|
||||
expect(syntax.getStyle("function.builtin")?.fg?.equals(theme.error)).toBe(false)
|
||||
} finally {
|
||||
syntax.destroy()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user