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 2dd9188308c874dd3204a3f8fa8f5efa258e1bc5..b832fb4e2ded8d5ccdc295f7fd429ed85df16c62 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 3638837af7eb70a4b823939cb3624a099f36fb4c..aba156633a3f5481040f3b3f82e5426bdc029825 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 d3921cdbc8096ce2a21acd28325c89cf14a383cc..773780a8e0109a69a7ce40907f4ba0438a765a4d 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 72482b4073724f7bb664a6f62624bdd2e5eb6e1c..f4a451529e2d9a5d3fa832b8bff95afe0675a942 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 d3921cdbc8096ce2a21acd28325c89cf14a383cc..773780a8e0109a69a7ce40907f4ba0438a765a4d 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 326928252e837c7784cc4db2217a00f2905f0fae..1811167719c2a6cb8af9c06d273319be3032f235 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 aba156633a3f5481040f3b3f82e5426bdc029825..e271d8583c661b62f1a0bf5f4c848ca34cdbdc9d 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 f4a451529e2d9a5d3fa832b8bff95afe0675a942..d717c5d45985c6015e52b12df94b826257bfb8fc 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 1811167719c2a6cb8af9c06d273319be3032f235..cd6d46a771dbd3d3814ef03e4f657b03800481a3 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 b93148ae2cff53809a7a4fe390c532e8ef726fa7..a787443f31b00487ef6c8463fd4045dd18a2baca 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 007c871ffaf33edddf634aa467dd86ce9e718377..064ec61a378beb00417e6b6716a6f1358daa5cbf 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 b832fb4e2ded8d5ccdc295f7fd429ed85df16c62..bcfa01ca5c6aca231d444026af94c7f6c6b32f51 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 773780a8e0109a69a7ce40907f4ba0438a765a4d..bd1986b6b3aa9d00c3596f4b8e927c7961078219 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 118af92aaaff8fdf28ba75aa0456931f04fb5aa2..71ab963d82664db4dd9a66b9e9ac0e85449caf57 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 d717c5d45985c6015e52b12df94b826257bfb8fc..98ea1ee40ea1f3bebf13ae392e9c3192bbe79c51 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 773780a8e0109a69a7ce40907f4ba0438a765a4d..bd1986b6b3aa9d00c3596f4b8e927c7961078219 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