feat(highlight): migrate to tree-house with Helix queries
Replace tree-sitter-highlight dep with tree-house crate from Helix editor. Add ropey dependency required by tree-house. Reorganize query files from Helix's runtime/queries/ for all 14 supported languages: - bash, c, css, go, html, javascript, json, markdown, nix, python, rust, toml, typescript, yaml - Include ecma, _javascript, _typescript base dirs for JS/TS inheritance - Copy highlights.scm, injections.scm, locals.scm where available This commit establishes the foundation; highlight.rs implementation will follow in subsequent commits.
This commit is contained in:
148
queries/_typescript/highlights.scm
Normal file
148
queries/_typescript/highlights.scm
Normal file
@@ -0,0 +1,148 @@
|
||||
; Namespaces
|
||||
; ----------
|
||||
|
||||
(internal_module
|
||||
[((identifier) @namespace) ((nested_identifier (identifier) @namespace))])
|
||||
|
||||
(ambient_declaration "global" @namespace)
|
||||
|
||||
; Parameters
|
||||
; ----------
|
||||
; Javascript and Typescript Treesitter grammars deviate when defining the
|
||||
; tree structure for parameters, so we need to address them in each specific
|
||||
; language instead of ecma.
|
||||
|
||||
; (p: t)
|
||||
; (p: t = 1)
|
||||
(required_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
; (...p: t)
|
||||
(required_parameter
|
||||
(rest_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
; ({ p }: { p: t })
|
||||
(required_parameter
|
||||
(object_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.parameter))
|
||||
|
||||
; ({ a: p }: { a: t })
|
||||
(required_parameter
|
||||
(object_pattern
|
||||
(pair_pattern
|
||||
value: (identifier) @variable.parameter)))
|
||||
|
||||
; ([ p ]: t[])
|
||||
(required_parameter
|
||||
(array_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
; (p?: t)
|
||||
; (p?: t = 1) // Invalid but still possible to highlight.
|
||||
(optional_parameter
|
||||
(identifier) @variable.parameter)
|
||||
|
||||
; (...p?: t) // Invalid but still possible to highlight.
|
||||
(optional_parameter
|
||||
(rest_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
; ({ p }: { p?: t})
|
||||
(optional_parameter
|
||||
(object_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.parameter))
|
||||
|
||||
; ({ a: p }: { a?: t })
|
||||
(optional_parameter
|
||||
(object_pattern
|
||||
(pair_pattern
|
||||
value: (identifier) @variable.parameter)))
|
||||
|
||||
; ([ p ]?: t[]) // Invalid but still possible to highlight.
|
||||
(optional_parameter
|
||||
(array_pattern
|
||||
(identifier) @variable.parameter))
|
||||
|
||||
(public_field_definition) @punctuation.special
|
||||
(this_type) @variable.builtin
|
||||
(type_predicate) @keyword.operator
|
||||
|
||||
; Punctuation
|
||||
; -----------
|
||||
|
||||
[
|
||||
":"
|
||||
] @punctuation.delimiter
|
||||
|
||||
(optional_parameter "?" @punctuation.special)
|
||||
(property_signature "?" @punctuation.special)
|
||||
|
||||
(conditional_type ["?" ":"] @operator)
|
||||
(ternary_expression ["?" ":"] @operator)
|
||||
|
||||
; Keywords
|
||||
; --------
|
||||
|
||||
[
|
||||
"abstract"
|
||||
"declare"
|
||||
"module"
|
||||
"export"
|
||||
"infer"
|
||||
"implements"
|
||||
"keyof"
|
||||
"namespace"
|
||||
"override"
|
||||
"satisfies"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"type"
|
||||
"interface"
|
||||
"enum"
|
||||
] @keyword.storage.type
|
||||
|
||||
[
|
||||
"public"
|
||||
"private"
|
||||
"protected"
|
||||
"readonly"
|
||||
] @keyword.storage.modifier
|
||||
|
||||
; Types
|
||||
; -----
|
||||
|
||||
(type_identifier) @type
|
||||
(type_parameter
|
||||
name: (type_identifier) @type.parameter)
|
||||
(predefined_type) @type.builtin
|
||||
|
||||
; Type arguments and parameters
|
||||
; -----------------------------
|
||||
|
||||
(type_arguments
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
(type_parameters
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
||||
(omitting_type_annotation) @punctuation.special
|
||||
(opting_type_annotation) @punctuation.special
|
||||
|
||||
; Literals
|
||||
; --------
|
||||
|
||||
[
|
||||
(template_literal_type)
|
||||
] @string
|
||||
|
||||
(import_require_clause
|
||||
(identifier) "="
|
||||
("require") @keyword)
|
||||
34
queries/_typescript/locals.scm
Normal file
34
queries/_typescript/locals.scm
Normal file
@@ -0,0 +1,34 @@
|
||||
; Scopes
|
||||
;-------
|
||||
|
||||
[
|
||||
(type_alias_declaration)
|
||||
(class_declaration)
|
||||
(interface_declaration)
|
||||
] @local.scope
|
||||
|
||||
; Definitions
|
||||
;------------
|
||||
|
||||
(type_parameter
|
||||
name: (type_identifier) @local.definition.type.parameter)
|
||||
|
||||
; Javascript and Typescript Treesitter grammars deviate when defining the
|
||||
; tree structure for parameters, so we need to address them in each specific
|
||||
; language instead of ecma.
|
||||
|
||||
; (i: t)
|
||||
; (i: t = 1)
|
||||
(required_parameter
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
; (i?: t)
|
||||
; (i?: t = 1) // Invalid but still possible to highlight.
|
||||
(optional_parameter
|
||||
(identifier) @local.definition.variable.parameter)
|
||||
|
||||
; References
|
||||
;-----------
|
||||
|
||||
(type_identifier) @local.reference
|
||||
(identifier) @local.reference
|
||||
Reference in New Issue
Block a user