From 070c4bc503b752b2632f34f8313bf2e71439eb64 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 7 Oct 2022 12:44:20 -0700 Subject: [PATCH 1/4] Add color for 'variable.special' and use it in highlight queries --- crates/zed/src/languages/cpp/highlights.scm | 2 +- crates/zed/src/languages/css/highlights.scm | 11 +++++++---- crates/zed/src/languages/javascript/highlights.scm | 4 ++-- crates/zed/src/languages/rust/highlights.scm | 2 +- crates/zed/src/languages/typescript/highlights.scm | 4 ++-- styles/src/themes/common/base16.ts | 4 ++++ 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/zed/src/languages/cpp/highlights.scm b/crates/zed/src/languages/cpp/highlights.scm index 2dd9188308..b832fb4e2d 100644 --- a/crates/zed/src/languages/cpp/highlights.scm +++ b/crates/zed/src/languages/cpp/highlights.scm @@ -41,7 +41,7 @@ (field_identifier) @property (statement_identifier) @label -(this) @variable.builtin +(this) @variable.special [ "break" diff --git a/crates/zed/src/languages/css/highlights.scm b/crates/zed/src/languages/css/highlights.scm index 3638837af7..aba156633a 100644 --- a/crates/zed/src/languages/css/highlights.scm +++ b/crates/zed/src/languages/css/highlights.scm @@ -41,10 +41,13 @@ (function_name) @function -((property_name) @variable - (#match? @variable "^--")) -((plain_value) @variable - (#match? @variable "^--")) +( + [ + (property_name) + (plain_value) + ] @variable.special + (#match? @variable.special "^--") +) [ "@media" diff --git a/crates/zed/src/languages/javascript/highlights.scm b/crates/zed/src/languages/javascript/highlights.scm index d3921cdbc8..773780a8e0 100644 --- a/crates/zed/src/languages/javascript/highlights.scm +++ b/crates/zed/src/languages/javascript/highlights.scm @@ -55,8 +55,8 @@ ; Literals -(this) @variable.builtin -(super) @variable.builtin +(this) @variable.special +(super) @variable.special [ (true) diff --git a/crates/zed/src/languages/rust/highlights.scm b/crates/zed/src/languages/rust/highlights.scm index 72482b4073..f4a451529e 100644 --- a/crates/zed/src/languages/rust/highlights.scm +++ b/crates/zed/src/languages/rust/highlights.scm @@ -1,6 +1,6 @@ (type_identifier) @type (primitive_type) @type.builtin -(self) @variable.builtin +(self) @variable.special (field_identifier) @property (call_expression diff --git a/crates/zed/src/languages/typescript/highlights.scm b/crates/zed/src/languages/typescript/highlights.scm index d3921cdbc8..773780a8e0 100644 --- a/crates/zed/src/languages/typescript/highlights.scm +++ b/crates/zed/src/languages/typescript/highlights.scm @@ -55,8 +55,8 @@ ; Literals -(this) @variable.builtin -(super) @variable.builtin +(this) @variable.special +(super) @variable.special [ (true) diff --git a/styles/src/themes/common/base16.ts b/styles/src/themes/common/base16.ts index 326928252e..1811167719 100644 --- a/styles/src/themes/common/base16.ts +++ b/styles/src/themes/common/base16.ts @@ -185,6 +185,10 @@ export function createTheme( color: sample(ramps.neutral, 7), weight: fontWeights.normal, }, + "variable.special": { + color: sample(ramps.blue, 0.80), + weight: fontWeights.normal, + }, comment: { color: sample(ramps.neutral, 5), weight: fontWeights.normal, From fcf13b44fb0be7e41323fadeb8e9626ce0c26767 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 7 Oct 2022 12:44:39 -0700 Subject: [PATCH 2/4] CSS: color '#' the same as the rest of the color --- crates/zed/src/languages/css/highlights.scm | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/zed/src/languages/css/highlights.scm b/crates/zed/src/languages/css/highlights.scm index aba156633a..e271d8583c 100644 --- a/crates/zed/src/languages/css/highlights.scm +++ b/crates/zed/src/languages/css/highlights.scm @@ -73,7 +73,6 @@ (unit) @type [ - "#" "," ":" ] @punctuation.delimiter From 95cb9ceac9d7e90f0aa2138edff711c0ced17c45 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 7 Oct 2022 12:44:55 -0700 Subject: [PATCH 3/4] Collapse variant and type into the same color --- crates/zed/src/languages/rust/highlights.scm | 13 ++----------- styles/src/themes/common/base16.ts | 8 ++------ styles/src/themes/common/theme.ts | 2 +- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/crates/zed/src/languages/rust/highlights.scm b/crates/zed/src/languages/rust/highlights.scm index f4a451529e..d717c5d459 100644 --- a/crates/zed/src/languages/rust/highlights.scm +++ b/crates/zed/src/languages/rust/highlights.scm @@ -27,17 +27,8 @@ ; Identifier conventions -; Assume uppercase names are enum constructors -((identifier) @variant - (#match? @variant "^[A-Z]")) - -; Assume that uppercase names in paths are types -((scoped_identifier - path: (identifier) @type) - (#match? @type "^[A-Z]")) -((scoped_identifier - path: (scoped_identifier - name: (identifier) @type)) +; Assume uppercase names are types/enum-constructors +((identifier) @type (#match? @type "^[A-Z]")) ; Assume all-caps names are constants diff --git a/styles/src/themes/common/base16.ts b/styles/src/themes/common/base16.ts index 1811167719..cd6d46a771 100644 --- a/styles/src/themes/common/base16.ts +++ b/styles/src/themes/common/base16.ts @@ -214,15 +214,11 @@ export function createTheme( weight: fontWeights.normal, }, constructor: { - color: sample(ramps.blue, 0.5), - weight: fontWeights.normal, - }, - variant: { - color: sample(ramps.blue, 0.5), + color: sample(ramps.cyan, 0.5), weight: fontWeights.normal, }, property: { - color: sample(ramps.blue, 0.5), + color: sample(ramps.blue, 0.6), weight: fontWeights.normal, }, enum: { diff --git a/styles/src/themes/common/theme.ts b/styles/src/themes/common/theme.ts index b93148ae2c..a787443f31 100644 --- a/styles/src/themes/common/theme.ts +++ b/styles/src/themes/common/theme.ts @@ -43,7 +43,7 @@ export interface Syntax { keyword: SyntaxHighlightStyle; function: SyntaxHighlightStyle; type: SyntaxHighlightStyle; - variant: SyntaxHighlightStyle; + constructor: SyntaxHighlightStyle; property: SyntaxHighlightStyle; enum: SyntaxHighlightStyle; operator: SyntaxHighlightStyle; From 6ecf870c665514ba7c812dad52d6cd629f1c5c84 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 7 Oct 2022 12:46:49 -0700 Subject: [PATCH 4/4] Tweak SCREAMING_SNAKE_CASE regexes in highlight queries --- crates/zed/src/languages/c/highlights.scm | 2 +- crates/zed/src/languages/cpp/highlights.scm | 2 +- crates/zed/src/languages/javascript/highlights.scm | 2 +- crates/zed/src/languages/python/highlights.scm | 2 +- crates/zed/src/languages/rust/highlights.scm | 2 +- crates/zed/src/languages/typescript/highlights.scm | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/zed/src/languages/c/highlights.scm b/crates/zed/src/languages/c/highlights.scm index 007c871ffa..064ec61a37 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) diff --git a/crates/zed/src/languages/cpp/highlights.scm b/crates/zed/src/languages/cpp/highlights.scm index b832fb4e2d..bcfa01ca5c 100644 --- a/crates/zed/src/languages/cpp/highlights.scm +++ b/crates/zed/src/languages/cpp/highlights.scm @@ -37,7 +37,7 @@ (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/javascript/highlights.scm b/crates/zed/src/languages/javascript/highlights.scm index 773780a8e0..bd1986b6b3 100644 --- a/crates/zed/src/languages/javascript/highlights.scm +++ b/crates/zed/src/languages/javascript/highlights.scm @@ -51,7 +51,7 @@ (shorthand_property_identifier) (shorthand_property_identifier_pattern) ] @constant - (#match? @constant "^[A-Z_][A-Z\\d_]+$")) + (#match? @constant "^_*[A-Z_][A-Z\\d_]*$")) ; Literals diff --git a/crates/zed/src/languages/python/highlights.scm b/crates/zed/src/languages/python/highlights.scm index 118af92aaa..71ab963d82 100644 --- a/crates/zed/src/languages/python/highlights.scm +++ b/crates/zed/src/languages/python/highlights.scm @@ -21,7 +21,7 @@ (#match? @type "^[A-Z]")) ((identifier) @constant - (#match? @constant "^[A-Z][A-Z_]*$")) + (#match? @constant "^_*[A-Z][A-Z\\d_]*$")) ; Builtin functions diff --git a/crates/zed/src/languages/rust/highlights.scm b/crates/zed/src/languages/rust/highlights.scm index d717c5d459..98ea1ee40e 100644 --- a/crates/zed/src/languages/rust/highlights.scm +++ b/crates/zed/src/languages/rust/highlights.scm @@ -33,7 +33,7 @@ ; 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/typescript/highlights.scm b/crates/zed/src/languages/typescript/highlights.scm index 773780a8e0..bd1986b6b3 100644 --- a/crates/zed/src/languages/typescript/highlights.scm +++ b/crates/zed/src/languages/typescript/highlights.scm @@ -51,7 +51,7 @@ (shorthand_property_identifier) (shorthand_property_identifier_pattern) ] @constant - (#match? @constant "^[A-Z_][A-Z\\d_]+$")) + (#match? @constant "^_*[A-Z_][A-Z\\d_]*$")) ; Literals