Skip to content

Commit

Permalink
JS/TS highlighting improvements (helix-editor#3219)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp-M authored and GreasySlug committed Aug 2, 2022
1 parent 956386d commit 699af11
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
5 changes: 5 additions & 0 deletions runtime/queries/javascript/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
;-----------

(property_identifier) @variable.other.member
(shorthand_property_identifier) @variable.other.member
(shorthand_property_identifier_pattern) @variable.other.member

; Literals
;---------
Expand Down Expand Up @@ -149,8 +151,11 @@
"&&="
"||="
"??="
"..."
] @operator

(ternary_expression ["?" ":"] @operator)

[
"("
")"
Expand Down
44 changes: 33 additions & 11 deletions runtime/queries/typescript/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
; inherits: javascript

; Types
; Namespaces

(type_identifier) @type
(predefined_type) @type.builtin
(internal_module
[((identifier) @namespace) ((nested_identifier (identifier) @namespace))])

((identifier) @type
(#match? @type "^[A-Z]"))
(ambient_declaration "global" @namespace)

(type_arguments
"<" @punctuation.bracket
">" @punctuation.bracket)

; Variables

(required_parameter (identifier) @variable.parameter)
(optional_parameter (identifier) @variable.parameter)

; Punctuation

[
":"
] @punctuation.delimiter

(optional_parameter "?" @punctuation.special)
(property_signature "?" @punctuation.special)

(conditional_type ["?" ":"] @operator)



; Keywords

[
"abstract"
"declare"
"export"
"infer"
"implements"
"keyof"
"namespace"
Expand All @@ -39,4 +47,18 @@
"private"
"protected"
"readonly"
] @keyword.storage.modifier
] @keyword.storage.modifier

; inherits: javascript

; Types

(type_identifier) @type
(predefined_type) @type.builtin

(type_arguments
"<" @punctuation.bracket
">" @punctuation.bracket)

((identifier) @type
(#match? @type "^[A-Z]"))

0 comments on commit 699af11

Please sign in to comment.