From 85f193dd09a099741cfb2c527c925cc20f0b9f6b Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 27 Jul 2023 12:25:53 -0400 Subject: [PATCH 1/5] Extract syntax highlighting properties from tree-sitter highlight queries --- crates/zed/src/languages/lua/highlights.scm | 4 +- crates/zed/src/languages/php/highlights.scm | 4 +- .../src/languages/typescript/highlights.scm | 6 +- styles/src/style_tree/editor.ts | 30 +- styles/src/theme/create_theme.ts | 11 +- styles/src/theme/syntax.ts | 382 +++--------------- styles/src/theme/theme_config.ts | 4 +- styles/src/theme/tokens/theme.ts | 6 +- styles/src/themes/atelier/common.ts | 5 +- styles/src/themes/ayu/common.ts | 6 +- styles/src/themes/gruvbox/gruvbox-common.ts | 6 +- styles/src/themes/one/one-dark.ts | 4 +- styles/src/themes/one/one-light.ts | 2 - styles/src/themes/rose-pine/common.ts | 4 +- styles/src/types/extract_syntax_types.ts | 102 +++++ styles/src/types/syntax.ts | 203 ++++++++++ 16 files changed, 419 insertions(+), 360 deletions(-) create mode 100644 styles/src/types/extract_syntax_types.ts create mode 100644 styles/src/types/syntax.ts diff --git a/crates/zed/src/languages/lua/highlights.scm b/crates/zed/src/languages/lua/highlights.scm index f061bbf8f91651605a7bcf946dcb576a82045aa6..60ca9de36b15098e9c76eaddff20238d5056adea 100644 --- a/crates/zed/src/languages/lua/highlights.scm +++ b/crates/zed/src/languages/lua/highlights.scm @@ -158,7 +158,7 @@ [ "{" "}" -] @constructor) +] @method.constructor) ;; Functions @@ -195,4 +195,4 @@ (number) @number -(string) @string \ No newline at end of file +(string) @string diff --git a/crates/zed/src/languages/php/highlights.scm b/crates/zed/src/languages/php/highlights.scm index fcb087c47d14dbc036ed79a50be7ff1b57ebc4e8..cfb03cbccad037d207ff1a1388c12eec22644f48 100644 --- a/crates/zed/src/languages/php/highlights.scm +++ b/crates/zed/src/languages/php/highlights.scm @@ -47,8 +47,8 @@ ((name) @constant.builtin (#match? @constant.builtin "^__[A-Z][A-Z\d_]+__$")) -((name) @constructor - (#match? @constructor "^[A-Z]")) +((name) @method.constructor +(#match? @method.constructor "^[A-Z]")) ((name) @variable.builtin (#eq? @variable.builtin "this")) diff --git a/crates/zed/src/languages/typescript/highlights.scm b/crates/zed/src/languages/typescript/highlights.scm index bf086ea156f6ee9c2aca6bb9d2ebdd3f91997999..ba6b329e0e0def9c5d0c31d0df94525825ed2c45 100644 --- a/crates/zed/src/languages/typescript/highlights.scm +++ b/crates/zed/src/languages/typescript/highlights.scm @@ -43,8 +43,8 @@ ; Special identifiers -((identifier) @constructor - (#match? @constructor "^[A-Z]")) +((identifier) @method.constructor + (#match? @method.constructor "^[A-Z]")) ((identifier) @type (#match? @type "^[A-Z]")) @@ -218,4 +218,4 @@ "type" "readonly" "override" -] @keyword \ No newline at end of file +] @keyword diff --git a/styles/src/style_tree/editor.ts b/styles/src/style_tree/editor.ts index acf983e8bee13f24d2897191c283217e1ee2ee55..ccbb33e21dd8459f665531b9b4b19af8831946bd 100644 --- a/styles/src/style_tree/editor.ts +++ b/styles/src/style_tree/editor.ts @@ -9,9 +9,9 @@ import { } from "./components" import hover_popover from "./hover_popover" -import { build_syntax } from "../theme/syntax" import { interactive, toggleable } from "../element" import { useTheme } from "../theme" +import chroma from "chroma-js" export default function editor(): any { const theme = useTheme() @@ -48,16 +48,28 @@ export default function editor(): any { } } - const syntax = build_syntax() - return { - text_color: syntax.primary.color, + text_color: theme.syntax.primary.color, background: background(layer), active_line_background: with_opacity(background(layer, "on"), 0.75), highlighted_line_background: background(layer, "on"), // Inline autocomplete suggestions, Co-pilot suggestions, etc. - hint: syntax.hint, - suggestion: syntax.predictive, + hint: chroma + .mix( + theme.ramps.neutral(0.6).hex(), + theme.ramps.blue(0.4).hex(), + 0.45, + "lch" + ) + .hex(), + suggestion: chroma + .mix( + theme.ramps.neutral(0.4).hex(), + theme.ramps.blue(0.4).hex(), + 0.45, + "lch" + ) + .hex(), code_actions: { indicator: toggleable({ base: interactive({ @@ -255,8 +267,8 @@ export default function editor(): any { invalid_warning_diagnostic: diagnostic(theme.middle, "base"), hover_popover: hover_popover(), link_definition: { - color: syntax.link_uri.color, - underline: syntax.link_uri.underline, + color: theme.syntax.link_uri.color, + underline: theme.syntax.link_uri.underline, }, jump_icon: interactive({ base: { @@ -314,6 +326,6 @@ export default function editor(): any { color: border_color(layer), }, }, - syntax, + syntax: theme.syntax, } } diff --git a/styles/src/theme/create_theme.ts b/styles/src/theme/create_theme.ts index d2701f8341af973a3a4511c149c983cb221fa14d..e52c4dc95b361572d8cbdc388c04146cecc81e8c 100644 --- a/styles/src/theme/create_theme.ts +++ b/styles/src/theme/create_theme.ts @@ -1,12 +1,12 @@ import { Scale, Color } from "chroma-js" -import { Syntax, ThemeSyntax, SyntaxHighlightStyle } from "./syntax" -export { Syntax, ThemeSyntax, SyntaxHighlightStyle } import { ThemeConfig, ThemeAppearance, - ThemeConfigInputColors, + ThemeConfigInputColors } from "./theme_config" import { get_ramps } from "./ramps" +import { syntaxStyle } from "./syntax" +import { Syntax } from "../types/syntax" export interface Theme { name: string @@ -31,7 +31,7 @@ export interface Theme { modal_shadow: Shadow players: Players - syntax?: Partial + syntax: Syntax } export interface Meta { @@ -119,7 +119,6 @@ export function create_theme(theme: ThemeConfig): Theme { name, appearance, input_color, - override: { syntax }, } = theme const is_light = appearance === ThemeAppearance.Light @@ -162,6 +161,8 @@ export function create_theme(theme: ThemeConfig): Theme { "7": player(ramps.yellow), } + const syntax = syntaxStyle(ramps, theme.override.syntax ? theme.override.syntax : {}) + return { name, is_light, diff --git a/styles/src/theme/syntax.ts b/styles/src/theme/syntax.ts index 540a1d0ff9822d5a8c2cf292ddba5ace6839ac6d..d39496a412904647ea2deb8c74048c864ab31550 100644 --- a/styles/src/theme/syntax.ts +++ b/styles/src/theme/syntax.ts @@ -1,332 +1,80 @@ import deepmerge from "deepmerge" -import { FontWeight, font_weights, useTheme } from "../common" -import chroma from "chroma-js" +import { font_weights, ThemeConfigInputSyntax, RampSet } from "../common" +import { Syntax, SyntaxHighlightStyle, allSyntaxKeys } from "../types/syntax" -export interface SyntaxHighlightStyle { - color?: string - weight?: FontWeight - underline?: boolean - italic?: boolean -} - -export interface Syntax { - // == Text Styles ====== / - comment: SyntaxHighlightStyle - // elixir: doc comment - "comment.doc": SyntaxHighlightStyle - primary: SyntaxHighlightStyle - predictive: SyntaxHighlightStyle - hint: SyntaxHighlightStyle - - // === Formatted Text ====== / - emphasis: SyntaxHighlightStyle - "emphasis.strong": SyntaxHighlightStyle - title: SyntaxHighlightStyle - link_uri: SyntaxHighlightStyle - link_text: SyntaxHighlightStyle - /** md: indented_code_block, fenced_code_block, code_span */ - "text.literal": SyntaxHighlightStyle - - // == Punctuation ====== / - punctuation: SyntaxHighlightStyle - /** Example: `(`, `[`, `{`...*/ - "punctuation.bracket": SyntaxHighlightStyle - /**., ;*/ - "punctuation.delimiter": SyntaxHighlightStyle - // js, ts: ${, } in a template literal - // yaml: *, &, ---, ... - "punctuation.special": SyntaxHighlightStyle - // md: list_marker_plus, list_marker_dot, etc - "punctuation.list_marker": SyntaxHighlightStyle - - // == Strings ====== / - - string: SyntaxHighlightStyle - // css: color_value - // js: this, super - // toml: offset_date_time, local_date_time... - "string.special": SyntaxHighlightStyle - // elixir: atom, quoted_atom, keyword, quoted_keyword - // ruby: simple_symbol, delimited_symbol... - "string.special.symbol"?: SyntaxHighlightStyle - // elixir, python, yaml...: escape_sequence - "string.escape"?: SyntaxHighlightStyle - // Regular expressions - "string.regex"?: SyntaxHighlightStyle - - // == Types ====== / - // We allow Function here because all JS objects literals have this property - constructor: SyntaxHighlightStyle | Function // eslint-disable-line @typescript-eslint/ban-types - variant: SyntaxHighlightStyle - type: SyntaxHighlightStyle - // js: predefined_type - "type.builtin"?: SyntaxHighlightStyle - - // == Values - variable: SyntaxHighlightStyle - // this, ... - // css: -- (var(--foo)) - // lua: self - "variable.special"?: SyntaxHighlightStyle - // c: statement_identifier, - label: SyntaxHighlightStyle - // css: tag_name, nesting_selector, universal_selector... - tag: SyntaxHighlightStyle - // css: attribute, pseudo_element_selector (tag_name), - attribute: SyntaxHighlightStyle - // css: class_name, property_name, namespace_name... - property: SyntaxHighlightStyle - // true, false, null, nullptr - constant: SyntaxHighlightStyle - // css: @media, @import, @supports... - // js: declare, implements, interface, keyof, public... - keyword: SyntaxHighlightStyle - // note: js enum is currently defined as a keyword - enum: SyntaxHighlightStyle - // -, --, ->, !=, &&, ||, <=... - operator: SyntaxHighlightStyle - number: SyntaxHighlightStyle - boolean: SyntaxHighlightStyle - // elixir: __MODULE__, __DIR__, __ENV__, etc - // go: nil, iota - "constant.builtin"?: SyntaxHighlightStyle - - // == Functions ====== / - - function: SyntaxHighlightStyle - // lua: assert, error, loadfile, tostring, unpack... - "function.builtin"?: SyntaxHighlightStyle - // go: call_expression, method_declaration - // js: call_expression, method_definition, pair (key, arrow function) - // rust: function_item name: (identifier) - "function.definition"?: SyntaxHighlightStyle - // rust: macro_definition name: (identifier) - "function.special.definition"?: SyntaxHighlightStyle - "function.method"?: SyntaxHighlightStyle - // ruby: identifier/"defined?" // Nate note: I don't fully understand this one. - "function.method.builtin"?: SyntaxHighlightStyle - - // == Unsorted ====== / - // lua: hash_bang_line - preproc: SyntaxHighlightStyle - // elixir, python: interpolation (ex: foo in ${foo}) - // js: template_substitution - embedded: SyntaxHighlightStyle -} - -export type ThemeSyntax = Partial +// Apply defaults to any missing syntax properties that are not defined manually +function apply_defaults(ramps: RampSet, syntax_highlights: Partial): Syntax { + const restKeys: (keyof Syntax)[] = allSyntaxKeys.filter(key => !syntax_highlights[key]) -const default_syntax_highlight_style: Omit = { - weight: "normal", - underline: false, - italic: false, -} - -function build_default_syntax(): Syntax { - const theme = useTheme() + const completeSyntax: Syntax = {} as Syntax - // Make a temporary object that is allowed to be missing - // the "color" property for each style - const syntax: { - [key: string]: Omit - } = {} + const defaults: SyntaxHighlightStyle = { + color: ramps.neutral(1).hex(), + } - // then spread the default to each style - for (const key of Object.keys({} as Syntax)) { - syntax[key as keyof Syntax] = { - ...default_syntax_highlight_style, + for (const key of restKeys) { + { + completeSyntax[key] = { + ...defaults, + } } } - // Mix the neutral and blue colors to get a - // predictive color distinct from any other color in the theme - const predictive = chroma - .mix( - theme.ramps.neutral(0.4).hex(), - theme.ramps.blue(0.4).hex(), - 0.45, - "lch" - ) - .hex() - // Mix the neutral and green colors to get a - // hint color distinct from any other color in the theme - const hint = chroma - .mix( - theme.ramps.neutral(0.6).hex(), - theme.ramps.blue(0.4).hex(), - 0.45, - "lch" - ) - .hex() + const mergedBaseSyntax = Object.assign(completeSyntax, syntax_highlights) - const color = { - primary: theme.ramps.neutral(1).hex(), - comment: theme.ramps.neutral(0.71).hex(), - punctuation: theme.ramps.neutral(0.86).hex(), - predictive: predictive, - hint: hint, - emphasis: theme.ramps.blue(0.5).hex(), - string: theme.ramps.orange(0.5).hex(), - function: theme.ramps.yellow(0.5).hex(), - type: theme.ramps.cyan(0.5).hex(), - constructor: theme.ramps.blue(0.5).hex(), - variant: theme.ramps.blue(0.5).hex(), - property: theme.ramps.blue(0.5).hex(), - enum: theme.ramps.orange(0.5).hex(), - operator: theme.ramps.orange(0.5).hex(), - number: theme.ramps.green(0.5).hex(), - boolean: theme.ramps.green(0.5).hex(), - constant: theme.ramps.green(0.5).hex(), - keyword: theme.ramps.blue(0.5).hex(), - } - - // Then assign colors and use Syntax to enforce each style getting it's own color - const default_syntax: Syntax = { - ...syntax, - comment: { - color: color.comment, - }, - "comment.doc": { - color: color.comment, - }, - primary: { - color: color.primary, - }, - predictive: { - color: color.predictive, - italic: true, - }, - hint: { - color: color.hint, - weight: font_weights.bold, - }, - emphasis: { - color: color.emphasis, - }, - "emphasis.strong": { - color: color.emphasis, - weight: font_weights.bold, - }, - title: { - color: color.primary, - weight: font_weights.bold, - }, - link_uri: { - color: theme.ramps.green(0.5).hex(), - underline: true, - }, - link_text: { - color: theme.ramps.orange(0.5).hex(), - italic: true, - }, - "text.literal": { - color: color.string, - }, - punctuation: { - color: color.punctuation, - }, - "punctuation.bracket": { - color: color.punctuation, - }, - "punctuation.delimiter": { - color: color.punctuation, - }, - "punctuation.special": { - color: theme.ramps.neutral(0.86).hex(), - }, - "punctuation.list_marker": { - color: color.punctuation, - }, - string: { - color: color.string, - }, - "string.special": { - color: color.string, - }, - "string.special.symbol": { - color: color.string, - }, - "string.escape": { - color: color.comment, - }, - "string.regex": { - color: color.string, - }, - constructor: { - color: theme.ramps.blue(0.5).hex(), - }, - variant: { - color: theme.ramps.blue(0.5).hex(), - }, - type: { - color: color.type, - }, - variable: { - color: color.primary, - }, - label: { - color: theme.ramps.blue(0.5).hex(), - }, - tag: { - color: theme.ramps.blue(0.5).hex(), - }, - attribute: { - color: theme.ramps.blue(0.5).hex(), - }, - property: { - color: theme.ramps.blue(0.5).hex(), - }, - constant: { - color: color.constant, - }, - keyword: { - color: color.keyword, - }, - enum: { - color: color.enum, - }, - operator: { - color: color.operator, - }, - number: { - color: color.number, - }, - boolean: { - color: color.boolean, - }, - function: { - color: color.function, - }, - preproc: { - color: color.primary, - }, - embedded: { - color: color.primary, - }, - } - - return default_syntax + return mergedBaseSyntax } -export function build_syntax(): Syntax { - const theme = useTheme() - - const default_syntax: Syntax = build_default_syntax() +// Merge the base syntax with the theme syntax overrides +// This is a deep merge, so any nested properties will be merged as well +// This allows for a theme to only override a single property of a syntax highlight style +const merge_syntax = (baseSyntax: Syntax, theme_syntax_overrides: ThemeConfigInputSyntax): Syntax => { + return deepmerge(baseSyntax, theme_syntax_overrides, { + arrayMerge: (destinationArray, sourceArray) => [ + ...destinationArray, + ...sourceArray, + ], + }) +} - if (!theme.syntax) { - return default_syntax +/** Returns a complete Syntax object of the combined styles of a theme's syntax overrides and the default syntax styles */ +export const syntaxStyle = (ramps: RampSet, theme_syntax_overrides: ThemeConfigInputSyntax): Syntax => { + const syntax_highlights: Partial = { + "comment": { color: ramps.neutral(0.71).hex() }, + "comment.doc": { color: ramps.neutral(0.71).hex() }, + primary: { color: ramps.neutral(1).hex() }, + emphasis: { color: ramps.blue(0.5).hex() }, + "emphasis.strong": { color: ramps.blue(0.5).hex(), weight: font_weights.bold }, + link_uri: { color: ramps.green(0.5).hex(), underline: true }, + link_text: { color: ramps.orange(0.5).hex(), italic: true }, + "text.literal": { color: ramps.orange(0.5).hex() }, + punctuation: { color: ramps.neutral(0.86).hex() }, + "punctuation.bracket": { color: ramps.neutral(0.86).hex() }, + "punctuation.special": { color: ramps.neutral(0.86).hex() }, + "punctuation.delimiter": { color: ramps.neutral(0.86).hex() }, + "punctuation.list_marker": { color: ramps.neutral(0.86).hex() }, + string: { color: ramps.orange(0.5).hex() }, + "string.special": { color: ramps.orange(0.5).hex() }, + "string.special.symbol": { color: ramps.orange(0.5).hex() }, + "string.escape": { color: ramps.neutral(0.71).hex() }, + "string.regex": { color: ramps.orange(0.5).hex() }, + "method.constructor": { color: ramps.blue(0.5).hex() }, + type: { color: ramps.cyan(0.5).hex() }, + variable: { color: ramps.neutral(1).hex() }, + label: { color: ramps.blue(0.5).hex() }, + attribute: { color: ramps.blue(0.5).hex() }, + property: { color: ramps.blue(0.5).hex() }, + constant: { color: ramps.green(0.5).hex() }, + keyword: { color: ramps.blue(0.5).hex() }, + operator: { color: ramps.orange(0.5).hex() }, + number: { color: ramps.green(0.5).hex() }, + boolean: { color: ramps.green(0.5).hex() }, + function: { color: ramps.yellow(0.5).hex() }, + preproc: { color: ramps.neutral(1).hex() }, + embedded: { color: ramps.neutral(1).hex() }, } - const syntax = deepmerge>( - default_syntax, - theme.syntax, - { - arrayMerge: (destinationArray, sourceArray) => [ - ...destinationArray, - ...sourceArray, - ], - } - ) - - return syntax + const baseSyntax = apply_defaults(ramps, syntax_highlights) + const mergedSyntax = merge_syntax(baseSyntax, theme_syntax_overrides) + return mergedSyntax } diff --git a/styles/src/theme/theme_config.ts b/styles/src/theme/theme_config.ts index bc8f07425f9e676a27d36ec929ea9a116006c694..8473bbb600608cac6157f894f3e9ac5d91c31a31 100644 --- a/styles/src/theme/theme_config.ts +++ b/styles/src/theme/theme_config.ts @@ -1,5 +1,5 @@ import { Scale, Color } from "chroma-js" -import { Syntax } from "./syntax" +import { SyntaxHighlightStyle, SyntaxProperty } from "../types/syntax" interface ThemeMeta { /** The name of the theme */ @@ -55,7 +55,7 @@ export type ThemeConfigInputColorsKeys = keyof ThemeConfigInputColors * } * ``` */ -export type ThemeConfigInputSyntax = Partial +export type ThemeConfigInputSyntax = Partial>> interface ThemeConfigOverrides { syntax: ThemeConfigInputSyntax diff --git a/styles/src/theme/tokens/theme.ts b/styles/src/theme/tokens/theme.ts index f759bc813910416d88a2097134dc95654d6ab3b3..f9e83e0512012e0c5d699ac432869a70520a9839 100644 --- a/styles/src/theme/tokens/theme.ts +++ b/styles/src/theme/tokens/theme.ts @@ -6,15 +6,13 @@ import { } from "@tokens-studio/types" import { Shadow, - SyntaxHighlightStyle, - ThemeSyntax, } from "../create_theme" import { LayerToken, layer_token } from "./layer" import { PlayersToken, players_token } from "./players" import { color_token } from "./token" -import { Syntax } from "../syntax" import editor from "../../style_tree/editor" import { useTheme } from "../../../src/common" +import { Syntax, SyntaxHighlightStyle } from "../../types/syntax" interface ThemeTokens { name: SingleOtherToken @@ -51,7 +49,7 @@ const modal_shadow_token = (): SingleBoxShadowToken => { return create_shadow_token(shadow, "modal_shadow") } -type ThemeSyntaxColorTokens = Record +type ThemeSyntaxColorTokens = Record function syntax_highlight_style_color_tokens( syntax: Syntax diff --git a/styles/src/themes/atelier/common.ts b/styles/src/themes/atelier/common.ts index b76ccc5b607a2f149a35114a519ddaaf2d1b254d..09226b336c0aae3d42a4e99130e1c46875d6065b 100644 --- a/styles/src/themes/atelier/common.ts +++ b/styles/src/themes/atelier/common.ts @@ -1,4 +1,4 @@ -import { ThemeLicenseType, ThemeSyntax, ThemeFamilyMeta } from "../../common" +import { ThemeLicenseType, ThemeFamilyMeta, ThemeConfigInputSyntax } from "../../common" export interface Variant { colors: { @@ -29,7 +29,7 @@ export const meta: ThemeFamilyMeta = { "https://atelierbram.github.io/syntax-highlighting/atelier-schemes/cave/", } -export const build_syntax = (variant: Variant): ThemeSyntax => { +export const build_syntax = (variant: Variant): ThemeConfigInputSyntax => { const { colors } = variant return { primary: { color: colors.base06 }, @@ -50,7 +50,6 @@ export const build_syntax = (variant: Variant): ThemeSyntax => { property: { color: colors.base08 }, variable: { color: colors.base06 }, "variable.special": { color: colors.base0E }, - variant: { color: colors.base0A }, keyword: { color: colors.base0E }, } } diff --git a/styles/src/themes/ayu/common.ts b/styles/src/themes/ayu/common.ts index 2bd0bbf259aef2d9fc6c084f1da3c72379927026..870445588646b57f347fe9e90e07b286b3b73790 100644 --- a/styles/src/themes/ayu/common.ts +++ b/styles/src/themes/ayu/common.ts @@ -3,8 +3,8 @@ import { chroma, color_ramp, ThemeLicenseType, - ThemeSyntax, ThemeFamilyMeta, + ThemeConfigInputSyntax, } from "../../common" export const ayu = { @@ -27,7 +27,7 @@ export const build_theme = (t: typeof dark, light: boolean) => { purple: t.syntax.constant.hex(), } - const syntax: ThemeSyntax = { + const syntax: ThemeConfigInputSyntax = { constant: { color: t.syntax.constant.hex() }, "string.regex": { color: t.syntax.regexp.hex() }, string: { color: t.syntax.string.hex() }, @@ -61,7 +61,7 @@ export const build_theme = (t: typeof dark, light: boolean) => { } } -export const build_syntax = (t: typeof dark): ThemeSyntax => { +export const build_syntax = (t: typeof dark): ThemeConfigInputSyntax => { return { constant: { color: t.syntax.constant.hex() }, "string.regex": { color: t.syntax.regexp.hex() }, diff --git a/styles/src/themes/gruvbox/gruvbox-common.ts b/styles/src/themes/gruvbox/gruvbox-common.ts index 2fa6b58faadb91b5689c5eac93baf706f6faa391..95e45efa95122ec3ca37d2dc57360ca55ec83e85 100644 --- a/styles/src/themes/gruvbox/gruvbox-common.ts +++ b/styles/src/themes/gruvbox/gruvbox-common.ts @@ -4,8 +4,8 @@ import { ThemeAppearance, ThemeLicenseType, ThemeConfig, - ThemeSyntax, ThemeFamilyMeta, + ThemeConfigInputSyntax, } from "../../common" const meta: ThemeFamilyMeta = { @@ -214,7 +214,7 @@ const build_variant = (variant: Variant): ThemeConfig => { magenta: color_ramp(chroma(variant.colors.gray)), } - const syntax: ThemeSyntax = { + const syntax: ThemeConfigInputSyntax = { primary: { color: neutral[is_light ? 0 : 8] }, "text.literal": { color: colors.blue }, comment: { color: colors.gray }, @@ -229,7 +229,7 @@ const build_variant = (variant: Variant): ThemeConfig => { "string.special.symbol": { color: colors.aqua }, "string.regex": { color: colors.orange }, type: { color: colors.yellow }, - enum: { color: colors.orange }, + // enum: { color: colors.orange }, tag: { color: colors.aqua }, constant: { color: colors.yellow }, keyword: { color: colors.red }, diff --git a/styles/src/themes/one/one-dark.ts b/styles/src/themes/one/one-dark.ts index f672b892ee040e60745f3d0f8bd6875c743ed46a..97f3922f36f57c7452c8face077a8b2bc8997858 100644 --- a/styles/src/themes/one/one-dark.ts +++ b/styles/src/themes/one/one-dark.ts @@ -54,7 +54,6 @@ export const theme: ThemeConfig = { syntax: { boolean: { color: color.orange }, comment: { color: color.grey }, - enum: { color: color.red }, "emphasis.strong": { color: color.orange }, function: { color: color.blue }, keyword: { color: color.purple }, @@ -73,8 +72,7 @@ export const theme: ThemeConfig = { "text.literal": { color: color.green }, type: { color: color.teal }, "variable.special": { color: color.orange }, - variant: { color: color.blue }, - constructor: { color: color.blue }, + "method.constructor": { color: color.blue }, }, }, } diff --git a/styles/src/themes/one/one-light.ts b/styles/src/themes/one/one-light.ts index c3de7826c96679fb1c1f2b1a9d81324687d919b9..655428757898a7f07f4524377721ab62ef1f5b53 100644 --- a/styles/src/themes/one/one-light.ts +++ b/styles/src/themes/one/one-light.ts @@ -55,7 +55,6 @@ export const theme: ThemeConfig = { syntax: { boolean: { color: color.orange }, comment: { color: color.grey }, - enum: { color: color.red }, "emphasis.strong": { color: color.orange }, function: { color: color.blue }, keyword: { color: color.purple }, @@ -73,7 +72,6 @@ export const theme: ThemeConfig = { "text.literal": { color: color.green }, type: { color: color.teal }, "variable.special": { color: color.orange }, - variant: { color: color.blue }, }, }, } diff --git a/styles/src/themes/rose-pine/common.ts b/styles/src/themes/rose-pine/common.ts index 5c5482a754a634bd2338af2613327554ec36d13c..decccc0a6dc8b1062ec8d5a88a699350a79bf322 100644 --- a/styles/src/themes/rose-pine/common.ts +++ b/styles/src/themes/rose-pine/common.ts @@ -1,4 +1,4 @@ -import { ThemeSyntax } from "../../common" +import { ThemeConfigInputSyntax } from "../../common" export const color = { default: { @@ -54,7 +54,7 @@ export const color = { }, } -export const syntax = (c: typeof color.default): Partial => { +export const syntax = (c: typeof color.default): ThemeConfigInputSyntax => { return { comment: { color: c.muted }, operator: { color: c.pine }, diff --git a/styles/src/types/extract_syntax_types.ts b/styles/src/types/extract_syntax_types.ts new file mode 100644 index 0000000000000000000000000000000000000000..3bf089518233a8b264e71853ad83e2634f9c1ab3 --- /dev/null +++ b/styles/src/types/extract_syntax_types.ts @@ -0,0 +1,102 @@ +import fs from 'fs' +import path from 'path' +import readline from 'readline' + +function escapeTypeName(name: string): string { + return `'${name.replace('@', '').toLowerCase()}'` +} + +const generatedNote = `// This file is generated by extract_syntax_types.ts +// Do not edit this file directly +// It is generated from the highlight.scm files in the zed crate + +// To regenerate this file manually: +// 'npm run extract-syntax-types' from ./styles` + +const defaultTextProperty = ` /** Default text color */ + | 'primary'` + +const main = async () => { + const pathFromRoot = 'crates/zed/src/languages' + const directoryPath = path.join(__dirname, '../../../', pathFromRoot) + const stylesMap: Record> = {} + const propertyLanguageMap: Record> = {} + + const processFile = async (filePath: string, language: string) => { + const fileStream = fs.createReadStream(filePath) + const rl = readline.createInterface({ + input: fileStream, + crlfDelay: Infinity, + }) + + for await (const line of rl) { + const cleanedLine = line.replace(/"@[a-zA-Z0-9_.]*"/g, "") + const match = cleanedLine.match(/@(\w+\.*)*/g) + if (match) { + match.forEach((property) => { + const formattedProperty = escapeTypeName(property) + // Only add non-empty properties + if (formattedProperty !== "''") { + if (!propertyLanguageMap[formattedProperty]) { + propertyLanguageMap[formattedProperty] = new Set() + } + propertyLanguageMap[formattedProperty].add(language) + } + }) + } + } + } + + const directories = fs.readdirSync(directoryPath, { withFileTypes: true }) + .filter(dirent => dirent.isDirectory()) + .map(dirent => dirent.name) + + for (const dir of directories) { + const highlightsFilePath = path.join(directoryPath, dir, 'highlights.scm') + if (fs.existsSync(highlightsFilePath)) { + await processFile(highlightsFilePath, dir) + } + } + + for (const [language, properties] of Object.entries(stylesMap)) { + console.log(`${language}: ${Array.from(properties).join(', ')}`) + } + + const sortedProperties = Object.entries(propertyLanguageMap).sort(([propA], [propB]) => propA.localeCompare(propB)) + + const outStream = fs.createWriteStream(path.join(__dirname, 'syntax.ts')) + let allProperties = "" + const syntaxKeys = [] + for (const [property, languages] of sortedProperties) { + let languagesArray = Array.from(languages) + const moreThanSeven = languagesArray.length > 7 + // Limit to the first 7 languages, append "..." if more than 7 + languagesArray = languagesArray.slice(0, 7) + if (moreThanSeven) { + languagesArray.push('...') + } + const languagesString = languagesArray.join(', ') + const comment = `/** ${languagesString} */` + allProperties += ` ${comment}\n | ${property} \n` + syntaxKeys.push(property) + } + outStream.write(`${generatedNote} + +export type SyntaxHighlightStyle = { + color: string, + fade_out?: number, + italic?: boolean, + underline?: boolean, + weight?: string, +} + +export type Syntax = Record +export type SyntaxOverride = Partial + +export type SyntaxProperty = \n${defaultTextProperty}\n\n${allProperties} + +export const allSyntaxKeys: SyntaxProperty[] = [\n ${syntaxKeys.join(',\n ')}\n]`) + outStream.end() +} + +main().catch(console.error) diff --git a/styles/src/types/syntax.ts b/styles/src/types/syntax.ts new file mode 100644 index 0000000000000000000000000000000000000000..b74edfdf8463e510c40fee84c35e5d22d6586d83 --- /dev/null +++ b/styles/src/types/syntax.ts @@ -0,0 +1,203 @@ +// This file is generated by extract_syntax_types.ts +// Do not edit this file directly +// It is generated from the highlight.scm files in the zed crate + +// To regenerate this file manually: +// 'npm run extract-syntax-types' from ./styles + +export type SyntaxHighlightStyle = { + color: string, + fade_out?: number, + italic?: boolean, + underline?: boolean, + weight?: string, +} + +export type Syntax = Record +export type SyntaxOverride = Partial + +export type SyntaxProperty = + /** Default text color */ + | 'primary' + + /** elixir */ + | '__attribute__' + /** elixir */ + | '__name__' + /** elixir */ + | '_sigil_name' + /** css, heex, lua */ + | 'attribute' + /** javascript, lua, tsx, typescript, yaml */ + | 'boolean' + /** elixir */ + | 'comment.doc' + /** elixir */ + | 'comment.unused' + /** bash, c, cpp, css, elixir, elm, erb, ... */ + | 'comment' + /** elixir, go, javascript, lua, php, python, racket, ... */ + | 'constant.builtin' + /** bash, c, cpp, elixir, elm, glsl, heex, ... */ + | 'constant' + /** glsl */ + | 'delimiter' + /** bash, elixir, javascript, python, ruby, tsx, typescript */ + | 'embedded' + /** markdown */ + | 'emphasis.strong' + /** markdown */ + | 'emphasis' + /** go, python, racket, ruby, scheme */ + | 'escape' + /** lua */ + | 'field' + /** lua, php, python */ + | 'function.builtin' + /** elm, lua, rust */ + | 'function.definition' + /** ruby */ + | 'function.method.builtin' + /** go, javascript, php, python, ruby, rust, tsx, ... */ + | 'function.method' + /** rust */ + | 'function.special.definition' + /** c, cpp, glsl, rust */ + | 'function.special' + /** bash, c, cpp, css, elixir, elm, glsl, ... */ + | 'function' + /** elm */ + | 'identifier' + /** glsl */ + | 'keyword.function' + /** bash, c, cpp, css, elixir, elm, erb, ... */ + | 'keyword' + /** c, cpp, glsl */ + | 'label' + /** markdown */ + | 'link_text' + /** markdown */ + | 'link_uri' + /** lua, php, tsx, typescript */ + | 'method.constructor' + /** lua */ + | 'method' + /** heex */ + | 'module' + /** svelte */ + | 'none' + /** bash, c, cpp, css, elixir, glsl, go, ... */ + | 'number' + /** bash, c, cpp, css, elixir, elm, glsl, ... */ + | 'operator' + /** lua */ + | 'parameter' + /** lua */ + | 'preproc' + /** bash, c, cpp, css, glsl, go, html, ... */ + | 'property' + /** c, cpp, elixir, elm, heex, html, javascript, ... */ + | 'punctuation.bracket' + /** c, cpp, css, elixir, elm, heex, javascript, ... */ + | 'punctuation.delimiter' + /** markdown */ + | 'punctuation.list_marker' + /** elixir, javascript, python, ruby, tsx, typescript, yaml */ + | 'punctuation.special' + /** elixir */ + | 'punctuation' + /** glsl */ + | 'storageclass' + /** elixir, elm, yaml */ + | 'string.escape' + /** elixir, javascript, racket, ruby, tsx, typescript */ + | 'string.regex' + /** elixir, ruby */ + | 'string.special.symbol' + /** css, elixir, toml */ + | 'string.special' + /** bash, c, cpp, css, elixir, elm, glsl, ... */ + | 'string' + /** svelte */ + | 'tag.delimiter' + /** css, heex, php, svelte */ + | 'tag' + /** markdown */ + | 'text.literal' + /** markdown */ + | 'title' + /** javascript, php, rust, tsx, typescript */ + | 'type.builtin' + /** glsl */ + | 'type.qualifier' + /** c, cpp, css, elixir, elm, glsl, go, ... */ + | 'type' + /** glsl, php */ + | 'variable.builtin' + /** cpp, css, javascript, lua, racket, ruby, rust, ... */ + | 'variable.special' + /** c, cpp, elm, glsl, go, javascript, lua, ... */ + | 'variable' + + +export const allSyntaxKeys: SyntaxProperty[] = [ + '__attribute__', + '__name__', + '_sigil_name', + 'attribute', + 'boolean', + 'comment.doc', + 'comment.unused', + 'comment', + 'constant.builtin', + 'constant', + 'delimiter', + 'embedded', + 'emphasis.strong', + 'emphasis', + 'escape', + 'field', + 'function.builtin', + 'function.definition', + 'function.method.builtin', + 'function.method', + 'function.special.definition', + 'function.special', + 'function', + 'identifier', + 'keyword.function', + 'keyword', + 'label', + 'link_text', + 'link_uri', + 'method.constructor', + 'method', + 'module', + 'none', + 'number', + 'operator', + 'parameter', + 'preproc', + 'property', + 'punctuation.bracket', + 'punctuation.delimiter', + 'punctuation.list_marker', + 'punctuation.special', + 'punctuation', + 'storageclass', + 'string.escape', + 'string.regex', + 'string.special.symbol', + 'string.special', + 'string', + 'tag.delimiter', + 'tag', + 'text.literal', + 'title', + 'type.builtin', + 'type.qualifier', + 'type', + 'variable.builtin', + 'variable.special', + 'variable' +] \ No newline at end of file From 86fa27eb54838e69292307c30ac611e0d32993c5 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 27 Jul 2023 12:41:19 -0400 Subject: [PATCH 2/5] Update uses of `#` to `.` in our scheme files where they are interchangeable. uses of `#` cause ERRORs in our scheme highlighting --- crates/zed/src/languages/bash/highlights.scm | 2 +- crates/zed/src/languages/c/highlights.scm | 3 +-- crates/zed/src/languages/c/injections.scm | 4 ++-- crates/zed/src/languages/cpp/highlights.scm | 4 ++-- crates/zed/src/languages/cpp/injections.scm | 4 ++-- crates/zed/src/languages/css/highlights.scm | 2 +- crates/zed/src/languages/elixir/embedding.scm | 6 +++--- crates/zed/src/languages/elixir/highlights.scm | 18 +++++++++--------- crates/zed/src/languages/elixir/injections.scm | 4 ++-- crates/zed/src/languages/elixir/outline.scm | 4 ++-- crates/zed/src/languages/elm/injections.scm | 2 +- crates/zed/src/languages/erb/injections.scm | 8 ++++---- crates/zed/src/languages/glsl/highlights.scm | 4 ++-- crates/zed/src/languages/heex/injections.scm | 6 +++--- crates/zed/src/languages/html/injections.scm | 4 ++-- .../src/languages/javascript/highlights.scm | 6 +++--- crates/zed/src/languages/lua/highlights.scm | 6 +++--- crates/zed/src/languages/php/highlights.scm | 8 ++++---- crates/zed/src/languages/php/injections.scm | 4 ++-- crates/zed/src/languages/python/highlights.scm | 8 ++++---- crates/zed/src/languages/racket/highlights.scm | 7 +++---- crates/zed/src/languages/racket/outline.scm | 4 ++-- crates/zed/src/languages/ruby/brackets.scm | 2 +- crates/zed/src/languages/ruby/highlights.scm | 8 ++++---- crates/zed/src/languages/rust/highlights.scm | 4 ++-- crates/zed/src/languages/rust/injections.scm | 4 ++-- crates/zed/src/languages/scheme/highlights.scm | 4 ++-- crates/zed/src/languages/scheme/outline.scm | 4 ++-- crates/zed/src/languages/svelte/injections.scm | 14 +++++++------- .../src/languages/typescript/highlights.scm | 6 +++--- 30 files changed, 81 insertions(+), 83 deletions(-) diff --git a/crates/zed/src/languages/bash/highlights.scm b/crates/zed/src/languages/bash/highlights.scm index a72c5468edd911b60b31c8ae07041c3f733f3497..f3e0c9529a1d7c19777e40c28f934c0b57e10941 100644 --- a/crates/zed/src/languages/bash/highlights.scm +++ b/crates/zed/src/languages/bash/highlights.scm @@ -54,5 +54,5 @@ ( (command (_) @constant) - (#match? @constant "^-") + (.match? @constant "^-") ) diff --git a/crates/zed/src/languages/c/highlights.scm b/crates/zed/src/languages/c/highlights.scm index 064ec61a378beb00417e6b6716a6f1358daa5cbf..5245e53a052578a62f8d4cddab8141bb0d80d288 100644 --- a/crates/zed/src/languages/c/highlights.scm +++ b/crates/zed/src/languages/c/highlights.scm @@ -86,7 +86,7 @@ (identifier) @variable ((identifier) @constant - (#match? @constant "^_*[A-Z][A-Z\\d_]*$")) + (.match? @constant "^_*[A-Z][A-Z\\d_]*$")) (call_expression function: (identifier) @function) @@ -106,4 +106,3 @@ (primitive_type) (sized_type_specifier) ] @type - diff --git a/crates/zed/src/languages/c/injections.scm b/crates/zed/src/languages/c/injections.scm index 845a63bd1bd4e700df0fd1eb3c5d10d31e2ab0e4..fbc7d83f8211836067a08cf05fae1b7b66170d12 100644 --- a/crates/zed/src/languages/c/injections.scm +++ b/crates/zed/src/languages/c/injections.scm @@ -1,7 +1,7 @@ (preproc_def value: (preproc_arg) @content - (#set! "language" "c")) + (.set! "language" "c")) (preproc_function_def value: (preproc_arg) @content - (#set! "language" "c")) \ No newline at end of file + (.set! "language" "c")) diff --git a/crates/zed/src/languages/cpp/highlights.scm b/crates/zed/src/languages/cpp/highlights.scm index bcfa01ca5c6aca231d444026af94c7f6c6b32f51..a040b1d053cd714a5576c8a6d9f13304c6c1392c 100644 --- a/crates/zed/src/languages/cpp/highlights.scm +++ b/crates/zed/src/languages/cpp/highlights.scm @@ -31,13 +31,13 @@ declarator: (field_identifier) @function) ((namespace_identifier) @type - (#match? @type "^[A-Z]")) + (.match? @type "^[A-Z]")) (auto) @type (type_identifier) @type ((identifier) @constant - (#match? @constant "^_*[A-Z][A-Z\\d_]*$")) + (.match? @constant "^_*[A-Z][A-Z\\d_]*$")) (field_identifier) @property (statement_identifier) @label diff --git a/crates/zed/src/languages/cpp/injections.scm b/crates/zed/src/languages/cpp/injections.scm index eca372d577be30c352a2b7f7d93505a3b869e293..3c94ba4061f6942fd88c7b09279b4f40a1709d14 100644 --- a/crates/zed/src/languages/cpp/injections.scm +++ b/crates/zed/src/languages/cpp/injections.scm @@ -1,7 +1,7 @@ (preproc_def value: (preproc_arg) @content - (#set! "language" "c++")) + (.set! "language" "c++")) (preproc_function_def value: (preproc_arg) @content - (#set! "language" "c++")) \ No newline at end of file + (.set! "language" "c++")) diff --git a/crates/zed/src/languages/css/highlights.scm b/crates/zed/src/languages/css/highlights.scm index e271d8583c661b62f1a0bf5f4c848ca34cdbdc9d..83f99861c59e19b9e60335f2f4cc10231d00e31b 100644 --- a/crates/zed/src/languages/css/highlights.scm +++ b/crates/zed/src/languages/css/highlights.scm @@ -46,7 +46,7 @@ (property_name) (plain_value) ] @variable.special - (#match? @variable.special "^--") + (.match? @variable.special "^--") ) [ diff --git a/crates/zed/src/languages/elixir/embedding.scm b/crates/zed/src/languages/elixir/embedding.scm index 16ad20746d4b0c8697ff126fcc5150636cb8b794..3c523c248767dff3b855f9c623e66e5b3e03a4ae 100644 --- a/crates/zed/src/languages/elixir/embedding.scm +++ b/crates/zed/src/languages/elixir/embedding.scm @@ -3,7 +3,7 @@ operator: "@" operand: (call target: (identifier) @unary - (#match? @unary "^(doc)$")) + (.match? @unary "^(doc)$")) ) @context . (call @@ -18,10 +18,10 @@ target: (identifier) @name) operator: "when") ]) - (#match? @name "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @item + (.match? @name "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @item ) (call target: (identifier) @name (arguments (alias) @name) - (#match? @name "^(defmodule|defprotocol)$")) @item + (.match? @name "^(defmodule|defprotocol)$")) @item diff --git a/crates/zed/src/languages/elixir/highlights.scm b/crates/zed/src/languages/elixir/highlights.scm index 0e779d195c5e6e03404c783d9675fc223232c84d..a8fd7eb45a6c04de64f1c7aa00fbeeecb535a316 100644 --- a/crates/zed/src/languages/elixir/highlights.scm +++ b/crates/zed/src/languages/elixir/highlights.scm @@ -54,13 +54,13 @@ (sigil_name) @__name__ quoted_start: _ @string quoted_end: _ @string - (#match? @__name__ "^[sS]$")) @string + (.match? @__name__ "^[sS]$")) @string (sigil (sigil_name) @__name__ quoted_start: _ @string.regex quoted_end: _ @string.regex - (#match? @__name__ "^[rR]$")) @string.regex + (.match? @__name__ "^[rR]$")) @string.regex (sigil (sigil_name) @__name__ @@ -69,7 +69,7 @@ ( (identifier) @comment.unused - (#match? @comment.unused "^_") + (.match? @comment.unused "^_") ) (call @@ -91,7 +91,7 @@ operator: "|>" right: (identifier)) ]) - (#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$")) + (.match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$")) (binary_operator operator: "|>" @@ -99,15 +99,15 @@ (call target: (identifier) @keyword - (#match? @keyword "^(def|defdelegate|defexception|defguard|defguardp|defimpl|defmacro|defmacrop|defmodule|defn|defnp|defoverridable|defp|defprotocol|defstruct)$")) + (.match? @keyword "^(def|defdelegate|defexception|defguard|defguardp|defimpl|defmacro|defmacrop|defmodule|defn|defnp|defoverridable|defp|defprotocol|defstruct)$")) (call target: (identifier) @keyword - (#match? @keyword "^(alias|case|cond|else|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$")) + (.match? @keyword "^(alias|case|cond|else|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$")) ( (identifier) @constant.builtin - (#match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$") + (.match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$") ) (unary_operator @@ -121,7 +121,7 @@ (sigil) (boolean) ] @comment.doc)) - (#match? @__attribute__ "^(moduledoc|typedoc|doc)$")) + (.match? @__attribute__ "^(moduledoc|typedoc|doc)$")) (comment) @comment @@ -150,4 +150,4 @@ ((sigil (sigil_name) @_sigil_name (quoted_content) @embedded) - (#eq? @_sigil_name "H")) + (.eq? @_sigil_name "H")) diff --git a/crates/zed/src/languages/elixir/injections.scm b/crates/zed/src/languages/elixir/injections.scm index 4de229f1046ca39264ffb23dc98e565bfd74185b..5d445a7b820ed480a9545c638ba6e685be7c244a 100644 --- a/crates/zed/src/languages/elixir/injections.scm +++ b/crates/zed/src/languages/elixir/injections.scm @@ -3,5 +3,5 @@ ((sigil (sigil_name) @_sigil_name (quoted_content) @content) - (#eq? @_sigil_name "H") - (#set! language "heex")) + (.eq? @_sigil_name "H") + (.set! language "heex")) diff --git a/crates/zed/src/languages/elixir/outline.scm b/crates/zed/src/languages/elixir/outline.scm index a3311fb6d4640aa4ff5469c638022c1fde02e912..756d39651039c002ef79ec818ba63aee20523c20 100644 --- a/crates/zed/src/languages/elixir/outline.scm +++ b/crates/zed/src/languages/elixir/outline.scm @@ -1,7 +1,7 @@ (call target: (identifier) @context (arguments (alias) @name) - (#match? @context "^(defmodule|defprotocol)$")) @item + (.match? @context "^(defmodule|defprotocol)$")) @item (call target: (identifier) @context @@ -23,4 +23,4 @@ ")" @context.extra)) operator: "when") ]) - (#match? @context "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @item + (.match? @context "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @item diff --git a/crates/zed/src/languages/elm/injections.scm b/crates/zed/src/languages/elm/injections.scm index 0567320675a89c6649a191fdef950c6670d65707..3456f59a04af62c95fc26c7cec085123eb8b567d 100644 --- a/crates/zed/src/languages/elm/injections.scm +++ b/crates/zed/src/languages/elm/injections.scm @@ -1,2 +1,2 @@ ((glsl_content) @content - (#set! "language" "glsl")) + (.set! "language" "glsl")) diff --git a/crates/zed/src/languages/erb/injections.scm b/crates/zed/src/languages/erb/injections.scm index 7a69a818ef31d7fa3822466209b08c15280c6f5b..d9801015b7ca1f41f94b8be516f79b4c3c9365f6 100644 --- a/crates/zed/src/languages/erb/injections.scm +++ b/crates/zed/src/languages/erb/injections.scm @@ -1,7 +1,7 @@ ((code) @content - (#set! "language" "ruby") - (#set! "combined")) + (.set! "language" "ruby") + (.set! "combined")) ((content) @content - (#set! "language" "html") - (#set! "combined")) + (.set! "language" "html") + (.set! "combined")) diff --git a/crates/zed/src/languages/glsl/highlights.scm b/crates/zed/src/languages/glsl/highlights.scm index e4503c6fbba298afb1f2eddb82ce960af74b03c0..2378b8449b594d883ba19a0e5515369f5725522f 100644 --- a/crates/zed/src/languages/glsl/highlights.scm +++ b/crates/zed/src/languages/glsl/highlights.scm @@ -74,7 +74,7 @@ (sized_type_specifier) @type ((identifier) @constant - (#match? @constant "^[A-Z][A-Z\\d_]*$")) + (.match? @constant "^[A-Z][A-Z\\d_]*$")) (identifier) @variable @@ -114,5 +114,5 @@ ( (identifier) @variable.builtin - (#match? @variable.builtin "^gl_") + (.match? @variable.builtin "^gl_") ) diff --git a/crates/zed/src/languages/heex/injections.scm b/crates/zed/src/languages/heex/injections.scm index b503bcb28dc10911b9e57e74f7217a21ece549fb..1b63005cbfa02189e19a6a202c5beea0112c0946 100644 --- a/crates/zed/src/languages/heex/injections.scm +++ b/crates/zed/src/languages/heex/injections.scm @@ -5,9 +5,9 @@ (expression_value) (ending_expression_value) ] @content) - (#set! language "elixir") - (#set! combined) + (.set! language "elixir") + (.set! combined) ) ((expression (expression_value) @content) - (#set! language "elixir")) + (.set! language "elixir")) diff --git a/crates/zed/src/languages/html/injections.scm b/crates/zed/src/languages/html/injections.scm index 9084e373f217b95cf70bad9cc907d5d9cd127391..7d2ed0a225e7555c6f12a9b902863a2e9e2e0939 100644 --- a/crates/zed/src/languages/html/injections.scm +++ b/crates/zed/src/languages/html/injections.scm @@ -1,7 +1,7 @@ (script_element (raw_text) @content - (#set! "language" "javascript")) + (.set! "language" "javascript")) (style_element (raw_text) @content - (#set! "language" "css")) + (.set! "language" "css")) diff --git a/crates/zed/src/languages/javascript/highlights.scm b/crates/zed/src/languages/javascript/highlights.scm index 36ab21ca1ec854566ad716a13f5ab5725fa1acc9..7761bbb3a2dbdf0a66536f233be1df85c0724a11 100644 --- a/crates/zed/src/languages/javascript/highlights.scm +++ b/crates/zed/src/languages/javascript/highlights.scm @@ -44,7 +44,7 @@ ; Special identifiers ((identifier) @type - (#match? @type "^[A-Z]")) + (.match? @type "^[A-Z]")) (type_identifier) @type (predefined_type) @type.builtin @@ -53,7 +53,7 @@ (shorthand_property_identifier) (shorthand_property_identifier_pattern) ] @constant - (#match? @constant "^_*[A-Z_][A-Z\\d_]*$")) +(.match? @constant "^_*[A-Z_][A-Z\\d_]*$")) ; Literals @@ -214,4 +214,4 @@ "type" "readonly" "override" -] @keyword \ No newline at end of file +] @keyword diff --git a/crates/zed/src/languages/lua/highlights.scm b/crates/zed/src/languages/lua/highlights.scm index 60ca9de36b15098e9c76eaddff20238d5056adea..e00d0b9557c86bb6a6d395a727dae2a1f2593210 100644 --- a/crates/zed/src/languages/lua/highlights.scm +++ b/crates/zed/src/languages/lua/highlights.scm @@ -127,7 +127,7 @@ (identifier) @variable ((identifier) @variable.special - (#eq? @variable.special "self")) + (.eq? @variable.special "self")) (variable_list attribute: (attribute @@ -137,7 +137,7 @@ ;; Constants ((identifier) @constant - (#match? @constant "^[A-Z][A-Z_0-9]*$")) + (.match? @constant "^[A-Z][A-Z_0-9]*$")) (vararg_expression) @constant @@ -180,7 +180,7 @@ (function_call (identifier) @function.builtin - (#any-of? @function.builtin + (.any-of? @function.builtin ;; built-in functions in Lua 5.1 "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print" diff --git a/crates/zed/src/languages/php/highlights.scm b/crates/zed/src/languages/php/highlights.scm index cfb03cbccad037d207ff1a1388c12eec22644f48..fb85d997fad6585066ac621253fe9694467e8517 100644 --- a/crates/zed/src/languages/php/highlights.scm +++ b/crates/zed/src/languages/php/highlights.scm @@ -43,15 +43,15 @@ (relative_scope) @variable.builtin ((name) @constant - (#match? @constant "^_?[A-Z][A-Z\\d_]+$")) + (.match? @constant "^_?[A-Z][A-Z\\d_]+$")) ((name) @constant.builtin - (#match? @constant.builtin "^__[A-Z][A-Z\d_]+__$")) + (.match? @constant.builtin "^__[A-Z][A-Z\d_]+__$")) ((name) @method.constructor -(#match? @method.constructor "^[A-Z]")) +(.match? @method.constructor "^[A-Z]")) ((name) @variable.builtin - (#eq? @variable.builtin "this")) + (.eq? @variable.builtin "this")) (variable_name) @variable diff --git a/crates/zed/src/languages/php/injections.scm b/crates/zed/src/languages/php/injections.scm index 57abd8ea2b0576e7b936788b4a9880bc57fea798..725729337b240a9e58b1e392ab645809d235314e 100644 --- a/crates/zed/src/languages/php/injections.scm +++ b/crates/zed/src/languages/php/injections.scm @@ -1,3 +1,3 @@ ((text) @content - (#set! "language" "html") - (#set! "combined")) + (.set! "language" "html") + (.set! "combined")) diff --git a/crates/zed/src/languages/python/highlights.scm b/crates/zed/src/languages/python/highlights.scm index 71ab963d82664db4dd9a66b9e9ac0e85449caf57..b31bddaeb501158c8bf6370ca0de37a1d73b7a6a 100644 --- a/crates/zed/src/languages/python/highlights.scm +++ b/crates/zed/src/languages/python/highlights.scm @@ -18,16 +18,16 @@ ; Identifier naming conventions ((identifier) @type - (#match? @type "^[A-Z]")) + (.match? @type "^[A-Z]")) ((identifier) @constant - (#match? @constant "^_*[A-Z][A-Z\\d_]*$")) + (.match? @constant "^_*[A-Z][A-Z\\d_]*$")) ; Builtin functions ((call function: (identifier) @function.builtin) - (#match? + (.match? @function.builtin "^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$")) @@ -122,4 +122,4 @@ "yield" "match" "case" -] @keyword \ No newline at end of file +] @keyword diff --git a/crates/zed/src/languages/racket/highlights.scm b/crates/zed/src/languages/racket/highlights.scm index 2c0caf89357cfbe8f966bffbbc712272b3c1e59d..304b10a018b23eebcea9248d33e0f43edd50ea29 100644 --- a/crates/zed/src/languages/racket/highlights.scm +++ b/crates/zed/src/languages/racket/highlights.scm @@ -22,7 +22,7 @@ (lang_name) @variable.special ((symbol) @operator - (#match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$")) + (.match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$")) (list . @@ -31,10 +31,9 @@ (list . (symbol) @keyword - (#match? @keyword + (.match? @keyword "^(unit-from-context|for/last|syntax-case|match-let\\*-values|define-for-syntax|define/subexpression-pos-prop|set-field!|class-field-accessor|invoke-unit|#%stratified-body|for\\*/and|for\\*/weak-set|flat-rec-contract|for\\*/stream|planet|for/mutable-seteqv|log-error|delay|#%declare|prop:dict/contract|->d|lib|override\\*|define-local-member-name|send-generic|for\\*/hasheq|define-syntax|submod|except|include-at/relative-to/reader|public\\*|define-member-name|define/public|let\\*|for/and|for\\*/first|for|delay/strict|define-values-for-export|==|match-define-values|for/weak-seteq|for\\*/async|for/stream|for/weak-seteqv|set!-values|lambda|for\\*/product|augment-final\\*|pubment\\*|command-line|contract|case|struct-field-index|contract-struct|unless|for/hasheq|for/seteqv|with-method|define-values-for-syntax|for-template|pubment|for\\*/list|syntax-case\\*|init-field|define-serializable-class|=>|for/foldr/derived|letrec-syntaxes|overment\\*|unquote-splicing|_|inherit-field|for\\*|stream-lazy|match-lambda\\*|contract-pos/neg-doubling|unit/c|match-define|for\\*/set|unit/s|nor|#%expression|class/c|this%|place/context|super-make-object|when|set!|parametric->/c|syntax-id-rules|include/reader|compound-unit|override-final|get-field|gen:dict|for\\*/seteqv|for\\*/hash|#%provide|combine-out|link|with-contract-continuation-mark|define-struct/derived|stream\\*|λ|rename-out|define-serializable-class\\*|augment|define/augment|let|define-signature-form|letrec-syntax|abstract|define-namespace-anchor|#%module-begin|#%top-interaction|for\\*/weak-seteqv|do|define/subexpression-pos-prop/name|absent|send/apply|with-handlers\\*|all-from-out|provide-signature-elements|gen:stream|define/override-final|for\\*/mutable-seteqv|rename|quasisyntax/loc|instantiate|for/list|extends|include-at/relative-to|mixin|define/pubment|#%plain-lambda|except-out|#%plain-module-begin|init|for\\*/last|relative-in|define-unit/new-import-export|->dm|member-name-key|nand|interface\\*|struct|define/override|else|define/augment-final|failure-cont|open|log-info|define/final-prop|all-defined-out|for/sum|for\\*/sum|recursive-contract|define|define-logger|match\\*|log-debug|rename-inner|->|struct/derived|unit|class\\*|prefix-out|any|define/overment|define-signature|match-letrec-values|let-syntaxes|for/mutable-set|define/match|cond|super-instantiate|define-contract-struct|import|hash/dc|define-custom-set-types|public-final|for/vector|for-label|prefix-in|for\\*/foldr/derived|define-unit-binding|object-contract|syntax-rules|augride|for\\*/mutable-seteq|quasisyntax|inner|for-syntax|overment|send/keyword-apply|generic|let\\*-values|->m|define-values|struct-copy|init-depend|struct/ctc|match-lambda|#%printing-module-begin|match\\*/derived|case->m|this|file|stream-cons|inspect|field|for/weak-set|struct\\*|gen:custom-write|thunk\\*|combine-in|unquote|for/lists|define/private|for\\*/foldr|define-unit/s|with-continuation-mark|begin|prefix|quote-syntax/prune|object/c|interface|match/derived|for/hasheqv|current-contract-region|define-compound-unit|override|define/public-final|recontract-out|let/cc|augride\\*|inherit|send|define-values/invoke-unit|for/mutable-seteq|#%datum|for/first|match-let\\*|invoke-unit/infer|define/contract|syntax/loc|for\\*/hasheqv|define-sequence-syntax|let/ec|for/product|for\\*/fold/derived|define-syntax-rule|lazy|unconstrained-domain->|augment-final|private|class|define-splicing-for-clause-syntax|for\\*/fold|prompt-tag/c|contract-out|match/values|public-final\\*|case-lambda|for/fold|unsyntax|for/set|begin0|#%require|time|public|define-struct|include|define-values/invoke-unit/infer|only-space-in|struct/c|only-meta-in|unit/new-import-export|place|begin-for-syntax|shared|inherit/super|quote|for/or|struct/contract|export|inherit/inner|struct-out|let-syntax|augment\\*|for\\*/vector|rename-in|match-let|define-unit|:do-in|~@|for\\*/weak-seteq|private\\*|and|except-in|log-fatal|gen:equal\\+hash|provide|require|thunk|invariant-assertion|define-match-expander|init-rest|->\\*|class/derived|super-new|for/fold/derived|for\\*/mutable-set|match-lambda\\*\\*|only|with-contract|~\\?|opt/c|let-values|delay/thread|->i|for/foldr|for-meta|only-in|send\\+|\\.\\.\\.|struct-guard/c|->\\*m|gen:set|struct/dc|define-syntaxes|if|parameterize|module\\*|module|send\\*|#%variable-reference|compound-unit/infer|#%plain-app|for/hash|contracted|case->|match|for\\*/lists|#%app|letrec-values|log-warning|super|define/augride|local-require|provide/contract|define-struct/contract|match-let-values|quote-syntax|for\\*/seteq|define-compound-unit/infer|parameterize\\*|values/drop|for/seteq|tag|stream|delay/idle|module\\+|define-custom-hash-types|cons/dc|define-module-boundary-contract|or|protect-out|define-opt/c|implies|letrec-syntaxes\\+values|for\\*/or|unsyntax-splicing|override-final\\*|for/async|parameterize-break|syntax|place\\*|for-space|quasiquote|with-handlers|delay/sync|define-unit-from-context|match-letrec|#%top|define-unit/contract|delay/name|new|field-bound\\?|letrec|class-field-mutator|with-syntax|flat-murec-contract|rename-super|local)$" )) ((symbol) @comment - (#match? @comment "^#[cC][iIsS]$")) - + (.match? @comment "^#[cC][iIsS]$")) diff --git a/crates/zed/src/languages/racket/outline.scm b/crates/zed/src/languages/racket/outline.scm index 604e052a63f71badbe98ec1debc96a519dc49256..188067078de2676ebaeaba90fe98d508dc7d19e0 100644 --- a/crates/zed/src/languages/racket/outline.scm +++ b/crates/zed/src/languages/racket/outline.scm @@ -6,5 +6,5 @@ (symbol) @name (list . (symbol) @name) ] - (#match? @start-symbol "^define") -) @item \ No newline at end of file + (.match? @start-symbol "^define") +) @item diff --git a/crates/zed/src/languages/ruby/brackets.scm b/crates/zed/src/languages/ruby/brackets.scm index 957b20ecdb4524920ba30b9d202d94d101215ed5..f5129f8f310ce4b533c29c5e3fdb465844e5e68e 100644 --- a/crates/zed/src/languages/ruby/brackets.scm +++ b/crates/zed/src/languages/ruby/brackets.scm @@ -11,4 +11,4 @@ (begin "begin" @open "end" @close) (module "module" @open "end" @close) (_ . "def" @open "end" @close) -(_ . "class" @open "end" @close) \ No newline at end of file +(_ . "class" @open "end" @close) diff --git a/crates/zed/src/languages/ruby/highlights.scm b/crates/zed/src/languages/ruby/highlights.scm index 2610cfa1ccf07254c68c87d2e8013741d7d6969f..93cf2608f4ee7829c55718c42075b6cb986805a1 100644 --- a/crates/zed/src/languages/ruby/highlights.scm +++ b/crates/zed/src/languages/ruby/highlights.scm @@ -33,12 +33,12 @@ (identifier) @variable ((identifier) @keyword - (#match? @keyword "^(private|protected|public)$")) + (.match? @keyword "^(private|protected|public)$")) ; Function calls ((identifier) @function.method.builtin - (#eq? @function.method.builtin "require")) + (.eq? @function.method.builtin "require")) "defined?" @function.method.builtin @@ -60,7 +60,7 @@ ] @property ((identifier) @constant.builtin - (#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$")) + (.match? @constant.builtin "^__(FILE|LINE|ENCODING)__$")) (file) @constant.builtin (line) @constant.builtin @@ -71,7 +71,7 @@ ) @constant.builtin ((constant) @constant - (#match? @constant "^[A-Z\\d_]+$")) + (.match? @constant "^[A-Z\\d_]+$")) (constant) @type diff --git a/crates/zed/src/languages/rust/highlights.scm b/crates/zed/src/languages/rust/highlights.scm index 7240173a89260b22a9508a9984e40dc8b1ab7410..54dbfa00bd3195efadc965d3dca490d8c00b74bd 100644 --- a/crates/zed/src/languages/rust/highlights.scm +++ b/crates/zed/src/languages/rust/highlights.scm @@ -38,11 +38,11 @@ ; Assume uppercase names are types/enum-constructors ((identifier) @type - (#match? @type "^[A-Z]")) + (.match? @type "^[A-Z]")) ; Assume all-caps names are constants ((identifier) @constant - (#match? @constant "^_*[A-Z][A-Z\\d_]*$")) + (.match? @constant "^_*[A-Z][A-Z\\d_]*$")) [ "(" diff --git a/crates/zed/src/languages/rust/injections.scm b/crates/zed/src/languages/rust/injections.scm index 57ebea8539345c72145eaa44cffb09845f913406..78fde3752fd9722e33daf4ad747b4e557044d353 100644 --- a/crates/zed/src/languages/rust/injections.scm +++ b/crates/zed/src/languages/rust/injections.scm @@ -1,7 +1,7 @@ (macro_invocation (token_tree) @content - (#set! "language" "rust")) + (.set! "language" "rust")) (macro_rule (token_tree) @content - (#set! "language" "rust")) \ No newline at end of file + (.set! "language" "rust")) diff --git a/crates/zed/src/languages/scheme/highlights.scm b/crates/zed/src/languages/scheme/highlights.scm index 40ba61cd055948195023e2aa25db6f032acd674e..201b0e9276870afeb4f3ed7eb68de302af929b33 100644 --- a/crates/zed/src/languages/scheme/highlights.scm +++ b/crates/zed/src/languages/scheme/highlights.scm @@ -14,7 +14,7 @@ (directive)] @comment ((symbol) @operator - (#match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$")) + (.match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$")) (list . @@ -23,6 +23,6 @@ (list . (symbol) @keyword - (#match? @keyword + (.match? @keyword "^(define-syntax|let\\*|lambda|λ|case|=>|quote-splicing|unquote-splicing|set!|let|letrec|letrec-syntax|let-values|let\\*-values|do|else|define|cond|syntax-rules|unquote|begin|quote|let-syntax|and|if|quasiquote|letrec|delay|or|when|unless|identifier-syntax|assert|library|export|import|rename|only|except|prefix)$" )) diff --git a/crates/zed/src/languages/scheme/outline.scm b/crates/zed/src/languages/scheme/outline.scm index 604e052a63f71badbe98ec1debc96a519dc49256..188067078de2676ebaeaba90fe98d508dc7d19e0 100644 --- a/crates/zed/src/languages/scheme/outline.scm +++ b/crates/zed/src/languages/scheme/outline.scm @@ -6,5 +6,5 @@ (symbol) @name (list . (symbol) @name) ] - (#match? @start-symbol "^define") -) @item \ No newline at end of file + (.match? @start-symbol "^define") +) @item diff --git a/crates/zed/src/languages/svelte/injections.scm b/crates/zed/src/languages/svelte/injections.scm index 8c1ac9fcd0bb16cf59e792487985ac64d6a43f88..17719b325c0c3632e1f6d9bbf7cd131ed9362dcb 100755 --- a/crates/zed/src/languages/svelte/injections.scm +++ b/crates/zed/src/languages/svelte/injections.scm @@ -2,27 +2,27 @@ ; -------------- (script_element (raw_text) @content - (#set! "language" "javascript")) + (.set! "language" "javascript")) ((script_element (start_tag (attribute (quoted_attribute_value (attribute_value) @_language))) (raw_text) @content) - (#eq? @_language "ts") - (#set! "language" "typescript")) + (.eq? @_language "ts") + (.set! "language" "typescript")) ((script_element (start_tag (attribute (quoted_attribute_value (attribute_value) @_language))) (raw_text) @content) - (#eq? @_language "typescript") - (#set! "language" "typescript")) + (.eq? @_language "typescript") + (.set! "language" "typescript")) (style_element (raw_text) @content - (#set! "language" "css")) + (.set! "language" "css")) ((raw_text_expr) @content - (#set! "language" "javascript")) + (.set! "language" "javascript")) diff --git a/crates/zed/src/languages/typescript/highlights.scm b/crates/zed/src/languages/typescript/highlights.scm index ba6b329e0e0def9c5d0c31d0df94525825ed2c45..9272108670ac2729dd39f4b54f90b81eeb3218a4 100644 --- a/crates/zed/src/languages/typescript/highlights.scm +++ b/crates/zed/src/languages/typescript/highlights.scm @@ -44,10 +44,10 @@ ; Special identifiers ((identifier) @method.constructor - (#match? @method.constructor "^[A-Z]")) + (.match? @method.constructor "^[A-Z]")) ((identifier) @type - (#match? @type "^[A-Z]")) + (.match? @type "^[A-Z]")) (type_identifier) @type (predefined_type) @type.builtin @@ -56,7 +56,7 @@ (shorthand_property_identifier) (shorthand_property_identifier_pattern) ] @constant - (#match? @constant "^_*[A-Z_][A-Z\\d_]*$")) +(.match? @constant "^_*[A-Z_][A-Z\\d_]*$")) ; Literals From 0b7e75c25a6d98649e92aa5d6e4f709f7bd754d2 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 27 Jul 2023 12:55:32 -0400 Subject: [PATCH 3/5] Add the `generate-syntax` action --- styles/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/styles/package.json b/styles/package.json index 16e95d90d5bebb18e7cfffe88e8d0098b48eb00f..3a50ac537166bcde6c30b0bc822481a823cfc8a2 100644 --- a/styles/package.json +++ b/styles/package.json @@ -8,6 +8,7 @@ "build-licenses": "ts-node ./src/build_licenses.ts", "build-tokens": "ts-node ./src/build_tokens.ts", "build-types": "ts-node ./src/build_types.ts", + "generate-syntax": "ts-node ./src/types/extract_syntax_types.ts", "test": "vitest" }, "author": "Zed Industries (https://github.com/zed-industries/)", From b9d5cc5828617fb0e973c121f09645cb7e98fb62 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 27 Jul 2023 12:56:54 -0400 Subject: [PATCH 4/5] Format --- styles/src/build_themes.ts | 9 +- styles/src/build_tokens.ts | 4 +- styles/src/component/icon_button.ts | 5 +- styles/src/component/tab_bar_button.ts | 67 +++--- styles/src/component/text_button.ts | 5 +- styles/src/style_tree/app.ts | 2 +- styles/src/style_tree/assistant.ts | 69 ++++--- styles/src/style_tree/editor.ts | 2 +- styles/src/style_tree/feedback.ts | 2 +- styles/src/style_tree/picker.ts | 2 +- styles/src/style_tree/project_panel.ts | 16 +- styles/src/style_tree/status_bar.ts | 10 +- styles/src/style_tree/titlebar.ts | 4 +- styles/src/theme/create_theme.ts | 25 ++- styles/src/theme/syntax.ts | 42 ++-- styles/src/theme/theme_config.ts | 4 +- styles/src/theme/tokens/theme.ts | 4 +- styles/src/themes/atelier/common.ts | 6 +- styles/src/types/extract_syntax_types.ts | 41 ++-- styles/src/types/syntax.ts | 253 +++++++++++------------ styles/tsconfig.json | 4 +- 21 files changed, 299 insertions(+), 277 deletions(-) diff --git a/styles/src/build_themes.ts b/styles/src/build_themes.ts index 17575663a1f88b17870b1b146b47e7086bf3e2ba..4d262f8146ed907035e384dbefd28c0b838a467a 100644 --- a/styles/src/build_themes.ts +++ b/styles/src/build_themes.ts @@ -21,9 +21,7 @@ function clear_themes(theme_directory: string) { } } -const all_themes: Theme[] = themes.map((theme) => - create_theme(theme) -) +const all_themes: Theme[] = themes.map((theme) => create_theme(theme)) function write_themes(themes: Theme[], output_directory: string) { clear_themes(output_directory) @@ -34,10 +32,7 @@ function write_themes(themes: Theme[], output_directory: string) { const style_tree = app() const style_tree_json = JSON.stringify(style_tree, null, 2) const temp_path = path.join(temp_directory, `${theme.name}.json`) - const out_path = path.join( - output_directory, - `${theme.name}.json` - ) + const out_path = path.join(output_directory, `${theme.name}.json`) fs.writeFileSync(temp_path, style_tree_json) fs.renameSync(temp_path, out_path) console.log(`- ${out_path} created`) diff --git a/styles/src/build_tokens.ts b/styles/src/build_tokens.ts index fd6aa18ced50af53b6bcf4c3c386d1774c7ab00d..3c52b6d989640a93025ac5eafe5a959b8bc83163 100644 --- a/styles/src/build_tokens.ts +++ b/styles/src/build_tokens.ts @@ -83,8 +83,6 @@ function write_tokens(themes: Theme[], tokens_directory: string) { console.log(`- ${METADATA_FILE} created`) } -const all_themes: Theme[] = themes.map((theme) => - create_theme(theme) -) +const all_themes: Theme[] = themes.map((theme) => create_theme(theme)) write_tokens(all_themes, TOKENS_DIRECTORY) diff --git a/styles/src/component/icon_button.ts b/styles/src/component/icon_button.ts index 6887fc7c30e1f234fd043bb115c2658039b5f806..13dfce6d7762aaf2abc59f298fb6e22583435cf1 100644 --- a/styles/src/component/icon_button.ts +++ b/styles/src/component/icon_button.ts @@ -10,10 +10,7 @@ export type Margin = { } interface IconButtonOptions { - layer?: - | Theme["lowest"] - | Theme["middle"] - | Theme["highest"] + layer?: Theme["lowest"] | Theme["middle"] | Theme["highest"] color?: keyof Theme["lowest"] margin?: Partial } diff --git a/styles/src/component/tab_bar_button.ts b/styles/src/component/tab_bar_button.ts index 0c43e7010e5469c10f959e00f4df8d177963392f..9e7f9acfc314be75850128690d8d066dde520182 100644 --- a/styles/src/component/tab_bar_button.ts +++ b/styles/src/component/tab_bar_button.ts @@ -12,44 +12,47 @@ type TabBarButtonProps = TabBarButtonOptions & { state?: Partial>> } -export function tab_bar_button(theme: Theme, { icon, color = "base" }: TabBarButtonProps) { +export function tab_bar_button( + theme: Theme, + { icon, color = "base" }: TabBarButtonProps +) { const button_spacing = 8 - return ( - interactive({ - base: { - icon: { - color: foreground(theme.middle, color), - asset: icon, - dimensions: { - width: 15, - height: 15, - }, + return interactive({ + base: { + icon: { + color: foreground(theme.middle, color), + asset: icon, + dimensions: { + width: 15, + height: 15, }, - container: { - corner_radius: 4, - padding: { - top: 4, bottom: 4, left: 4, right: 4 - }, - margin: { - left: button_spacing / 2, - right: button_spacing / 2, - }, + }, + container: { + corner_radius: 4, + padding: { + top: 4, + bottom: 4, + left: 4, + right: 4, + }, + margin: { + left: button_spacing / 2, + right: button_spacing / 2, }, }, - state: { - hovered: { - container: { - background: background(theme.middle, color, "hovered"), - - } + }, + state: { + hovered: { + container: { + background: background(theme.middle, color, "hovered"), }, - clicked: { - container: { - background: background(theme.middle, color, "pressed"), - } + }, + clicked: { + container: { + background: background(theme.middle, color, "pressed"), }, }, - }) - ) + }, + }) } diff --git a/styles/src/component/text_button.ts b/styles/src/component/text_button.ts index 58b2a1cbf2ff31a8e4fc50b9e1165bca78ec6b4a..68ec01c92bf1ba12907675dbd4ee87a4f51e4b9c 100644 --- a/styles/src/component/text_button.ts +++ b/styles/src/component/text_button.ts @@ -9,10 +9,7 @@ import { useTheme, Theme } from "../theme" import { Margin } from "./icon_button" interface TextButtonOptions { - layer?: - | Theme["lowest"] - | Theme["middle"] - | Theme["highest"] + layer?: Theme["lowest"] | Theme["middle"] | Theme["highest"] color?: keyof Theme["lowest"] margin?: Partial text_properties?: TextProperties diff --git a/styles/src/style_tree/app.ts b/styles/src/style_tree/app.ts index ccfdd60a981f4d5e763ce35902b0456bf0d703cd..ee0aa133a04bd35202d381835e257ddca2b284cc 100644 --- a/styles/src/style_tree/app.ts +++ b/styles/src/style_tree/app.ts @@ -57,6 +57,6 @@ export default function app(): any { tooltip: tooltip(), terminal: terminal(), assistant: assistant(), - feedback: feedback() + feedback: feedback(), } } diff --git a/styles/src/style_tree/assistant.ts b/styles/src/style_tree/assistant.ts index cfc1f8d813648654a8fee608ea4d00dc30893b75..7df5434f91010f778d47dfc9170ef80b909df0cf 100644 --- a/styles/src/style_tree/assistant.ts +++ b/styles/src/style_tree/assistant.ts @@ -8,50 +8,48 @@ type RoleCycleButton = TextStyle & { } // TODO: Replace these with zed types type RemainingTokens = TextStyle & { - background: string, - margin: { top: number, right: number }, + background: string + margin: { top: number; right: number } padding: { - right: number, - left: number, - top: number, - bottom: number, - }, - corner_radius: number, + right: number + left: number + top: number + bottom: number + } + corner_radius: number } export default function assistant(): any { const theme = useTheme() - const interactive_role = (color: StyleSets): Interactive => { - return ( - interactive({ - base: { + const interactive_role = ( + color: StyleSets + ): Interactive => { + return interactive({ + base: { + ...text(theme.highest, "sans", color, { size: "sm" }), + }, + state: { + hovered: { ...text(theme.highest, "sans", color, { size: "sm" }), + background: background(theme.highest, color, "hovered"), }, - state: { - hovered: { - ...text(theme.highest, "sans", color, { size: "sm" }), - background: background(theme.highest, color, "hovered"), - }, - clicked: { - ...text(theme.highest, "sans", color, { size: "sm" }), - background: background(theme.highest, color, "pressed"), - } + clicked: { + ...text(theme.highest, "sans", color, { size: "sm" }), + background: background(theme.highest, color, "pressed"), }, - }) - ) + }, + }) } const tokens_remaining = (color: StyleSets): RemainingTokens => { - return ( - { - ...text(theme.highest, "mono", color, { size: "xs" }), - background: background(theme.highest, "on", "default"), - margin: { top: 12, right: 20 }, - padding: { right: 4, left: 4, top: 1, bottom: 1 }, - corner_radius: 6, - } - ) + return { + ...text(theme.highest, "mono", color, { size: "xs" }), + background: background(theme.highest, "on", "default"), + margin: { top: 12, right: 20 }, + padding: { right: 4, left: 4, top: 1, bottom: 1 }, + corner_radius: 6, + } } return { @@ -93,7 +91,10 @@ export default function assistant(): any { base: { background: background(theme.middle), padding: { top: 4, bottom: 4 }, - border: border(theme.middle, "default", { top: true, overlay: true }), + border: border(theme.middle, "default", { + top: true, + overlay: true, + }), }, state: { hovered: { @@ -101,7 +102,7 @@ export default function assistant(): any { }, clicked: { background: background(theme.middle, "pressed"), - } + }, }, }), saved_at: { diff --git a/styles/src/style_tree/editor.ts b/styles/src/style_tree/editor.ts index ccbb33e21dd8459f665531b9b4b19af8831946bd..832e77626491ff94f183d5ce1fe195f5a55a3780 100644 --- a/styles/src/style_tree/editor.ts +++ b/styles/src/style_tree/editor.ts @@ -318,7 +318,7 @@ export default function editor(): any { ? with_opacity(theme.ramps.green(0.5).hex(), 0.8) : with_opacity(theme.ramps.green(0.4).hex(), 0.8), }, - selections: foreground(layer, "accent") + selections: foreground(layer, "accent"), }, composition_mark: { underline: { diff --git a/styles/src/style_tree/feedback.ts b/styles/src/style_tree/feedback.ts index b1bd96e165466521804f86d547664c209c7c4671..0349359533041d4425df3d0c72d120ed18499a30 100644 --- a/styles/src/style_tree/feedback.ts +++ b/styles/src/style_tree/feedback.ts @@ -37,7 +37,7 @@ export default function feedback(): any { ...text(theme.highest, "mono", "on", "disabled"), background: background(theme.highest, "on", "disabled"), border: border(theme.highest, "on", "disabled"), - } + }, }, }), button_margin: 8, diff --git a/styles/src/style_tree/picker.ts b/styles/src/style_tree/picker.ts index 28ae85478794a22211dc67cb6ec56cce4bc805f1..317f600b1e2fca3f6b8756c3ba033fa22e6b0220 100644 --- a/styles/src/style_tree/picker.ts +++ b/styles/src/style_tree/picker.ts @@ -152,7 +152,7 @@ export default function picker(): any { 0.5 ), }, - } + }, }), } } diff --git a/styles/src/style_tree/project_panel.ts b/styles/src/style_tree/project_panel.ts index e239f9a84023088d988f74e709c6485ade8a9510..51958af145b50afd25510788ff0a530cc77a5a1d 100644 --- a/styles/src/style_tree/project_panel.ts +++ b/styles/src/style_tree/project_panel.ts @@ -64,17 +64,17 @@ export default function project_panel(): any { const unselected_default_style = merge( base_properties, unselected?.default ?? {}, - {}, + {} ) const unselected_hovered_style = merge( base_properties, { background: background(theme.middle, "hovered") }, - unselected?.hovered ?? {}, + unselected?.hovered ?? {} ) const unselected_clicked_style = merge( base_properties, { background: background(theme.middle, "pressed") }, - unselected?.clicked ?? {}, + unselected?.clicked ?? {} ) const selected_default_style = merge( base_properties, @@ -82,7 +82,7 @@ export default function project_panel(): any { background: background(theme.lowest), text: text(theme.lowest, "sans", { size: "sm" }), }, - selected_style?.default ?? {}, + selected_style?.default ?? {} ) const selected_hovered_style = merge( base_properties, @@ -90,7 +90,7 @@ export default function project_panel(): any { background: background(theme.lowest, "hovered"), text: text(theme.lowest, "sans", { size: "sm" }), }, - selected_style?.hovered ?? {}, + selected_style?.hovered ?? {} ) const selected_clicked_style = merge( base_properties, @@ -98,7 +98,7 @@ export default function project_panel(): any { background: background(theme.lowest, "pressed"), text: text(theme.lowest, "sans", { size: "sm" }), }, - selected_style?.clicked ?? {}, + selected_style?.clicked ?? {} ) return toggleable({ @@ -175,7 +175,7 @@ export default function project_panel(): any { default: { icon_color: foreground(theme.middle, "variant"), }, - }, + } ), cut_entry: entry( { @@ -190,7 +190,7 @@ export default function project_panel(): any { size: "sm", }), }, - }, + } ), filename_editor: { background: background(theme.middle, "on"), diff --git a/styles/src/style_tree/status_bar.ts b/styles/src/style_tree/status_bar.ts index 06afc378235ec843d64a28313a38c05d395f1962..8f50896207ca6853c49ff008d6252d01f44f6911 100644 --- a/styles/src/style_tree/status_bar.ts +++ b/styles/src/style_tree/status_bar.ts @@ -34,10 +34,14 @@ export default function status_bar(): any { ...text(layer, "mono", "variant", { size: "xs" }), }, active_language: text_button({ - color: "variant" + color: "variant", + }), + auto_update_progress_message: text(layer, "sans", "variant", { + size: "xs", + }), + auto_update_done_message: text(layer, "sans", "variant", { + size: "xs", }), - auto_update_progress_message: text(layer, "sans", "variant", { size: "xs" }), - auto_update_done_message: text(layer, "sans", "variant", { size: "xs" }), lsp_status: interactive({ base: { ...diagnostic_status_container, diff --git a/styles/src/style_tree/titlebar.ts b/styles/src/style_tree/titlebar.ts index 177a8c5bd8db0fa2290eda5e25c4160531d81e4b..fe0c53e87dac61bdfc93688eea13e74d583017a9 100644 --- a/styles/src/style_tree/titlebar.ts +++ b/styles/src/style_tree/titlebar.ts @@ -183,10 +183,10 @@ export function titlebar(): any { project_name_divider: text(theme.lowest, "sans", "variant"), project_menu_button: toggleable_text_button(theme, { - color: 'base', + color: "base", }), git_menu_button: toggleable_text_button(theme, { - color: 'variant', + color: "variant", }), // Collaborators diff --git a/styles/src/theme/create_theme.ts b/styles/src/theme/create_theme.ts index e52c4dc95b361572d8cbdc388c04146cecc81e8c..6df36d7077b934f2acc45f21422159872c6f551a 100644 --- a/styles/src/theme/create_theme.ts +++ b/styles/src/theme/create_theme.ts @@ -2,7 +2,7 @@ import { Scale, Color } from "chroma-js" import { ThemeConfig, ThemeAppearance, - ThemeConfigInputColors + ThemeConfigInputColors, } from "./theme_config" import { get_ramps } from "./ramps" import { syntaxStyle } from "./syntax" @@ -13,16 +13,16 @@ export interface Theme { is_light: boolean /** - * App background, other elements that should sit directly on top of the background. - */ + * App background, other elements that should sit directly on top of the background. + */ lowest: Layer /** - * Panels, tabs, other UI surfaces that sit on top of the background. - */ + * Panels, tabs, other UI surfaces that sit on top of the background. + */ middle: Layer /** - * Editors like code buffers, conversation editors, etc. - */ + * Editors like code buffers, conversation editors, etc. + */ highest: Layer ramps: RampSet @@ -115,11 +115,7 @@ export interface Style { } export function create_theme(theme: ThemeConfig): Theme { - const { - name, - appearance, - input_color, - } = theme + const { name, appearance, input_color } = theme const is_light = appearance === ThemeAppearance.Light const color_ramps: ThemeConfigInputColors = input_color @@ -161,7 +157,10 @@ export function create_theme(theme: ThemeConfig): Theme { "7": player(ramps.yellow), } - const syntax = syntaxStyle(ramps, theme.override.syntax ? theme.override.syntax : {}) + const syntax = syntaxStyle( + ramps, + theme.override.syntax ? theme.override.syntax : {} + ) return { name, diff --git a/styles/src/theme/syntax.ts b/styles/src/theme/syntax.ts index d39496a412904647ea2deb8c74048c864ab31550..b1bf5ed9307b87036656d902b892c56b627022a0 100644 --- a/styles/src/theme/syntax.ts +++ b/styles/src/theme/syntax.ts @@ -3,8 +3,13 @@ import { font_weights, ThemeConfigInputSyntax, RampSet } from "../common" import { Syntax, SyntaxHighlightStyle, allSyntaxKeys } from "../types/syntax" // Apply defaults to any missing syntax properties that are not defined manually -function apply_defaults(ramps: RampSet, syntax_highlights: Partial): Syntax { - const restKeys: (keyof Syntax)[] = allSyntaxKeys.filter(key => !syntax_highlights[key]) +function apply_defaults( + ramps: RampSet, + syntax_highlights: Partial +): Syntax { + const restKeys: (keyof Syntax)[] = allSyntaxKeys.filter( + (key) => !syntax_highlights[key] + ) const completeSyntax: Syntax = {} as Syntax @@ -28,23 +33,36 @@ function apply_defaults(ramps: RampSet, syntax_highlights: Partial): Syn // Merge the base syntax with the theme syntax overrides // This is a deep merge, so any nested properties will be merged as well // This allows for a theme to only override a single property of a syntax highlight style -const merge_syntax = (baseSyntax: Syntax, theme_syntax_overrides: ThemeConfigInputSyntax): Syntax => { - return deepmerge(baseSyntax, theme_syntax_overrides, { - arrayMerge: (destinationArray, sourceArray) => [ - ...destinationArray, - ...sourceArray, - ], - }) +const merge_syntax = ( + baseSyntax: Syntax, + theme_syntax_overrides: ThemeConfigInputSyntax +): Syntax => { + return deepmerge( + baseSyntax, + theme_syntax_overrides, + { + arrayMerge: (destinationArray, sourceArray) => [ + ...destinationArray, + ...sourceArray, + ], + } + ) } /** Returns a complete Syntax object of the combined styles of a theme's syntax overrides and the default syntax styles */ -export const syntaxStyle = (ramps: RampSet, theme_syntax_overrides: ThemeConfigInputSyntax): Syntax => { +export const syntaxStyle = ( + ramps: RampSet, + theme_syntax_overrides: ThemeConfigInputSyntax +): Syntax => { const syntax_highlights: Partial = { - "comment": { color: ramps.neutral(0.71).hex() }, + comment: { color: ramps.neutral(0.71).hex() }, "comment.doc": { color: ramps.neutral(0.71).hex() }, primary: { color: ramps.neutral(1).hex() }, emphasis: { color: ramps.blue(0.5).hex() }, - "emphasis.strong": { color: ramps.blue(0.5).hex(), weight: font_weights.bold }, + "emphasis.strong": { + color: ramps.blue(0.5).hex(), + weight: font_weights.bold, + }, link_uri: { color: ramps.green(0.5).hex(), underline: true }, link_text: { color: ramps.orange(0.5).hex(), italic: true }, "text.literal": { color: ramps.orange(0.5).hex() }, diff --git a/styles/src/theme/theme_config.ts b/styles/src/theme/theme_config.ts index 8473bbb600608cac6157f894f3e9ac5d91c31a31..f5f83590743278508ba16b7245c2e7fc8e4d2650 100644 --- a/styles/src/theme/theme_config.ts +++ b/styles/src/theme/theme_config.ts @@ -55,7 +55,9 @@ export type ThemeConfigInputColorsKeys = keyof ThemeConfigInputColors * } * ``` */ -export type ThemeConfigInputSyntax = Partial>> +export type ThemeConfigInputSyntax = Partial< + Record> +> interface ThemeConfigOverrides { syntax: ThemeConfigInputSyntax diff --git a/styles/src/theme/tokens/theme.ts b/styles/src/theme/tokens/theme.ts index f9e83e0512012e0c5d699ac432869a70520a9839..d93079366961a1079df0858ceef980a0b9b59aec 100644 --- a/styles/src/theme/tokens/theme.ts +++ b/styles/src/theme/tokens/theme.ts @@ -4,9 +4,7 @@ import { SingleOtherToken, TokenTypes, } from "@tokens-studio/types" -import { - Shadow, -} from "../create_theme" +import { Shadow } from "../create_theme" import { LayerToken, layer_token } from "./layer" import { PlayersToken, players_token } from "./players" import { color_token } from "./token" diff --git a/styles/src/themes/atelier/common.ts b/styles/src/themes/atelier/common.ts index 09226b336c0aae3d42a4e99130e1c46875d6065b..9a0029581c565b0eb820e7bc8686f62e5e3627b2 100644 --- a/styles/src/themes/atelier/common.ts +++ b/styles/src/themes/atelier/common.ts @@ -1,4 +1,8 @@ -import { ThemeLicenseType, ThemeFamilyMeta, ThemeConfigInputSyntax } from "../../common" +import { + ThemeLicenseType, + ThemeFamilyMeta, + ThemeConfigInputSyntax, +} from "../../common" export interface Variant { colors: { diff --git a/styles/src/types/extract_syntax_types.ts b/styles/src/types/extract_syntax_types.ts index 3bf089518233a8b264e71853ad83e2634f9c1ab3..eb21d2418b9c830099cffc0c03f9ecf4c88ba7ed 100644 --- a/styles/src/types/extract_syntax_types.ts +++ b/styles/src/types/extract_syntax_types.ts @@ -1,9 +1,9 @@ -import fs from 'fs' -import path from 'path' -import readline from 'readline' +import fs from "fs" +import path from "path" +import readline from "readline" function escapeTypeName(name: string): string { - return `'${name.replace('@', '').toLowerCase()}'` + return `'${name.replace("@", "").toLowerCase()}'` } const generatedNote = `// This file is generated by extract_syntax_types.ts @@ -17,8 +17,8 @@ const defaultTextProperty = ` /** Default text color */ | 'primary'` const main = async () => { - const pathFromRoot = 'crates/zed/src/languages' - const directoryPath = path.join(__dirname, '../../../', pathFromRoot) + const pathFromRoot = "crates/zed/src/languages" + const directoryPath = path.join(__dirname, "../../../", pathFromRoot) const stylesMap: Record> = {} const propertyLanguageMap: Record> = {} @@ -47,24 +47,31 @@ const main = async () => { } } - const directories = fs.readdirSync(directoryPath, { withFileTypes: true }) - .filter(dirent => dirent.isDirectory()) - .map(dirent => dirent.name) + const directories = fs + .readdirSync(directoryPath, { withFileTypes: true }) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => dirent.name) for (const dir of directories) { - const highlightsFilePath = path.join(directoryPath, dir, 'highlights.scm') + const highlightsFilePath = path.join( + directoryPath, + dir, + "highlights.scm" + ) if (fs.existsSync(highlightsFilePath)) { await processFile(highlightsFilePath, dir) } } for (const [language, properties] of Object.entries(stylesMap)) { - console.log(`${language}: ${Array.from(properties).join(', ')}`) + console.log(`${language}: ${Array.from(properties).join(", ")}`) } - const sortedProperties = Object.entries(propertyLanguageMap).sort(([propA], [propB]) => propA.localeCompare(propB)) + const sortedProperties = Object.entries(propertyLanguageMap).sort( + ([propA], [propB]) => propA.localeCompare(propB) + ) - const outStream = fs.createWriteStream(path.join(__dirname, 'syntax.ts')) + const outStream = fs.createWriteStream(path.join(__dirname, "syntax.ts")) let allProperties = "" const syntaxKeys = [] for (const [property, languages] of sortedProperties) { @@ -73,9 +80,9 @@ const main = async () => { // Limit to the first 7 languages, append "..." if more than 7 languagesArray = languagesArray.slice(0, 7) if (moreThanSeven) { - languagesArray.push('...') + languagesArray.push("...") } - const languagesString = languagesArray.join(', ') + const languagesString = languagesArray.join(", ") const comment = `/** ${languagesString} */` allProperties += ` ${comment}\n | ${property} \n` syntaxKeys.push(property) @@ -95,7 +102,9 @@ export type SyntaxOverride = Partial export type SyntaxProperty = \n${defaultTextProperty}\n\n${allProperties} -export const allSyntaxKeys: SyntaxProperty[] = [\n ${syntaxKeys.join(',\n ')}\n]`) +export const allSyntaxKeys: SyntaxProperty[] = [\n ${syntaxKeys.join( + ",\n " + )}\n]`) outStream.end() } diff --git a/styles/src/types/syntax.ts b/styles/src/types/syntax.ts index b74edfdf8463e510c40fee84c35e5d22d6586d83..9b23dbde3cc799090e1dd848706f2b96a88e7ba6 100644 --- a/styles/src/types/syntax.ts +++ b/styles/src/types/syntax.ts @@ -6,198 +6,197 @@ // 'npm run extract-syntax-types' from ./styles export type SyntaxHighlightStyle = { - color: string, - fade_out?: number, - italic?: boolean, - underline?: boolean, - weight?: string, + color: string + fade_out?: number + italic?: boolean + underline?: boolean + weight?: string } export type Syntax = Record export type SyntaxOverride = Partial -export type SyntaxProperty = +export type SyntaxProperty = /** Default text color */ - | 'primary' + | "primary" /** elixir */ - | '__attribute__' + | "__attribute__" /** elixir */ - | '__name__' + | "__name__" /** elixir */ - | '_sigil_name' + | "_sigil_name" /** css, heex, lua */ - | 'attribute' + | "attribute" /** javascript, lua, tsx, typescript, yaml */ - | 'boolean' + | "boolean" /** elixir */ - | 'comment.doc' + | "comment.doc" /** elixir */ - | 'comment.unused' + | "comment.unused" /** bash, c, cpp, css, elixir, elm, erb, ... */ - | 'comment' + | "comment" /** elixir, go, javascript, lua, php, python, racket, ... */ - | 'constant.builtin' + | "constant.builtin" /** bash, c, cpp, elixir, elm, glsl, heex, ... */ - | 'constant' + | "constant" /** glsl */ - | 'delimiter' + | "delimiter" /** bash, elixir, javascript, python, ruby, tsx, typescript */ - | 'embedded' + | "embedded" /** markdown */ - | 'emphasis.strong' + | "emphasis.strong" /** markdown */ - | 'emphasis' + | "emphasis" /** go, python, racket, ruby, scheme */ - | 'escape' + | "escape" /** lua */ - | 'field' + | "field" /** lua, php, python */ - | 'function.builtin' + | "function.builtin" /** elm, lua, rust */ - | 'function.definition' + | "function.definition" /** ruby */ - | 'function.method.builtin' + | "function.method.builtin" /** go, javascript, php, python, ruby, rust, tsx, ... */ - | 'function.method' + | "function.method" /** rust */ - | 'function.special.definition' + | "function.special.definition" /** c, cpp, glsl, rust */ - | 'function.special' + | "function.special" /** bash, c, cpp, css, elixir, elm, glsl, ... */ - | 'function' + | "function" /** elm */ - | 'identifier' + | "identifier" /** glsl */ - | 'keyword.function' + | "keyword.function" /** bash, c, cpp, css, elixir, elm, erb, ... */ - | 'keyword' + | "keyword" /** c, cpp, glsl */ - | 'label' + | "label" /** markdown */ - | 'link_text' + | "link_text" /** markdown */ - | 'link_uri' + | "link_uri" /** lua, php, tsx, typescript */ - | 'method.constructor' + | "method.constructor" /** lua */ - | 'method' + | "method" /** heex */ - | 'module' + | "module" /** svelte */ - | 'none' + | "none" /** bash, c, cpp, css, elixir, glsl, go, ... */ - | 'number' + | "number" /** bash, c, cpp, css, elixir, elm, glsl, ... */ - | 'operator' + | "operator" /** lua */ - | 'parameter' + | "parameter" /** lua */ - | 'preproc' + | "preproc" /** bash, c, cpp, css, glsl, go, html, ... */ - | 'property' + | "property" /** c, cpp, elixir, elm, heex, html, javascript, ... */ - | 'punctuation.bracket' + | "punctuation.bracket" /** c, cpp, css, elixir, elm, heex, javascript, ... */ - | 'punctuation.delimiter' + | "punctuation.delimiter" /** markdown */ - | 'punctuation.list_marker' + | "punctuation.list_marker" /** elixir, javascript, python, ruby, tsx, typescript, yaml */ - | 'punctuation.special' + | "punctuation.special" /** elixir */ - | 'punctuation' + | "punctuation" /** glsl */ - | 'storageclass' + | "storageclass" /** elixir, elm, yaml */ - | 'string.escape' + | "string.escape" /** elixir, javascript, racket, ruby, tsx, typescript */ - | 'string.regex' + | "string.regex" /** elixir, ruby */ - | 'string.special.symbol' + | "string.special.symbol" /** css, elixir, toml */ - | 'string.special' + | "string.special" /** bash, c, cpp, css, elixir, elm, glsl, ... */ - | 'string' + | "string" /** svelte */ - | 'tag.delimiter' + | "tag.delimiter" /** css, heex, php, svelte */ - | 'tag' + | "tag" /** markdown */ - | 'text.literal' + | "text.literal" /** markdown */ - | 'title' + | "title" /** javascript, php, rust, tsx, typescript */ - | 'type.builtin' + | "type.builtin" /** glsl */ - | 'type.qualifier' + | "type.qualifier" /** c, cpp, css, elixir, elm, glsl, go, ... */ - | 'type' + | "type" /** glsl, php */ - | 'variable.builtin' + | "variable.builtin" /** cpp, css, javascript, lua, racket, ruby, rust, ... */ - | 'variable.special' + | "variable.special" /** c, cpp, elm, glsl, go, javascript, lua, ... */ - | 'variable' - + | "variable" export const allSyntaxKeys: SyntaxProperty[] = [ - '__attribute__', - '__name__', - '_sigil_name', - 'attribute', - 'boolean', - 'comment.doc', - 'comment.unused', - 'comment', - 'constant.builtin', - 'constant', - 'delimiter', - 'embedded', - 'emphasis.strong', - 'emphasis', - 'escape', - 'field', - 'function.builtin', - 'function.definition', - 'function.method.builtin', - 'function.method', - 'function.special.definition', - 'function.special', - 'function', - 'identifier', - 'keyword.function', - 'keyword', - 'label', - 'link_text', - 'link_uri', - 'method.constructor', - 'method', - 'module', - 'none', - 'number', - 'operator', - 'parameter', - 'preproc', - 'property', - 'punctuation.bracket', - 'punctuation.delimiter', - 'punctuation.list_marker', - 'punctuation.special', - 'punctuation', - 'storageclass', - 'string.escape', - 'string.regex', - 'string.special.symbol', - 'string.special', - 'string', - 'tag.delimiter', - 'tag', - 'text.literal', - 'title', - 'type.builtin', - 'type.qualifier', - 'type', - 'variable.builtin', - 'variable.special', - 'variable' -] \ No newline at end of file + "__attribute__", + "__name__", + "_sigil_name", + "attribute", + "boolean", + "comment.doc", + "comment.unused", + "comment", + "constant.builtin", + "constant", + "delimiter", + "embedded", + "emphasis.strong", + "emphasis", + "escape", + "field", + "function.builtin", + "function.definition", + "function.method.builtin", + "function.method", + "function.special.definition", + "function.special", + "function", + "identifier", + "keyword.function", + "keyword", + "label", + "link_text", + "link_uri", + "method.constructor", + "method", + "module", + "none", + "number", + "operator", + "parameter", + "preproc", + "property", + "punctuation.bracket", + "punctuation.delimiter", + "punctuation.list_marker", + "punctuation.special", + "punctuation", + "storageclass", + "string.escape", + "string.regex", + "string.special.symbol", + "string.special", + "string", + "tag.delimiter", + "tag", + "text.literal", + "title", + "type.builtin", + "type.qualifier", + "type", + "variable.builtin", + "variable.special", + "variable", +] diff --git a/styles/tsconfig.json b/styles/tsconfig.json index 281bd74b215bd16426bb6a8f9d68ddeb5a5bea43..a1913027b705df7d349c78bcc6b74bb96851fe8c 100644 --- a/styles/tsconfig.json +++ b/styles/tsconfig.json @@ -24,7 +24,5 @@ "useUnknownInCatchVariables": false, "baseUrl": "." }, - "exclude": [ - "node_modules" - ] + "exclude": ["node_modules"] } From b08a2770b867951c38a4286ebf96223578f0fc4a Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 27 Jul 2023 13:02:40 -0400 Subject: [PATCH 5/5] Remove redundant `syntax_highlights` --- styles/src/theme/syntax.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/styles/src/theme/syntax.ts b/styles/src/theme/syntax.ts index b1bf5ed9307b87036656d902b892c56b627022a0..db8f98de663bcb3afa8e84ea851363a3f83cbd0c 100644 --- a/styles/src/theme/syntax.ts +++ b/styles/src/theme/syntax.ts @@ -78,7 +78,6 @@ export const syntaxStyle = ( "string.regex": { color: ramps.orange(0.5).hex() }, "method.constructor": { color: ramps.blue(0.5).hex() }, type: { color: ramps.cyan(0.5).hex() }, - variable: { color: ramps.neutral(1).hex() }, label: { color: ramps.blue(0.5).hex() }, attribute: { color: ramps.blue(0.5).hex() }, property: { color: ramps.blue(0.5).hex() }, @@ -88,8 +87,6 @@ export const syntaxStyle = ( number: { color: ramps.green(0.5).hex() }, boolean: { color: ramps.green(0.5).hex() }, function: { color: ramps.yellow(0.5).hex() }, - preproc: { color: ramps.neutral(1).hex() }, - embedded: { color: ramps.neutral(1).hex() }, } const baseSyntax = apply_defaults(ramps, syntax_highlights)