Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Improve Regex highlighting (#28183)

chbkf97546b6efc4
diff --git a/crates/languages/src/javascript/highlights.scm b/crates/languages/src/javascript/highlights.scm
index 1b2e047a1e6..a7bf70308c8 100644
--- a/crates/languages/src/javascript/highlights.scm
+++ b/crates/languages/src/javascript/highlights.scm
@@ -85,7 +85,7 @@
(escape_sequence) @string.escape
(regex) @string.regex
-(regex_flags) @keyword.regex
+(regex_flags) @keyword.operator.regex
(number) @number
; Tokens
@@ -145,6 +145,8 @@
"??="
] @operator
+(regex "/" @string.regex)
+
[
"("
")"
diff --git a/crates/languages/src/regex/highlights.scm b/crates/languages/src/regex/highlights.scm
index 3829c3834bc..b5adecf4729 100644
--- a/crates/languages/src/regex/highlights.scm
+++ b/crates/languages/src/regex/highlights.scm
@@ -20,7 +20,7 @@
(control_letter_escape)
(character_class_escape)
(control_escape)
-] @string.escape
+] @string.escape.regex
[
"*"
@@ -32,17 +32,19 @@
(start_assertion)
(end_assertion)
(any_character)
+ (lazy)
] @operator.regex
[
(boundary_assertion)
(non_boundary_assertion)
(backreference_escape)
+ (decimal_escape)
] @keyword.operator.regex
(count_quantifier
[
- (decimal_digits) @number
+ (decimal_digits) @number.quantifier.regex
"," @punctuation.delimiter.regex
])
diff --git a/crates/languages/src/tsx/highlights.scm b/crates/languages/src/tsx/highlights.scm
index 6e1ced93ccd..9a707fa0ceb 100644
--- a/crates/languages/src/tsx/highlights.scm
+++ b/crates/languages/src/tsx/highlights.scm
@@ -86,7 +86,7 @@
(escape_sequence) @string.escape
(regex) @string.regex
-(regex_flags) @keyword.regex
+(regex_flags) @keyword.operator.regex
(number) @number
; Tokens
@@ -147,6 +147,8 @@
"??="
] @operator
+(regex "/" @string.regex)
+
[
"("
")"
diff --git a/crates/languages/src/typescript/highlights.scm b/crates/languages/src/typescript/highlights.scm
index b8399978638..3e628981c4f 100644
--- a/crates/languages/src/typescript/highlights.scm
+++ b/crates/languages/src/typescript/highlights.scm
@@ -113,7 +113,7 @@
(escape_sequence) @string.escape
(regex) @string.regex
-(regex_flags) @keyword.regex
+(regex_flags) @keyword.operator.regex
(number) @number
; Tokens
@@ -166,6 +166,8 @@
"??="
] @operator
+(regex "/" @string.regex)
+
(ternary_expression
[
"?"