2024-04-23 20:29:59 -07:00
|
|
|
; inherits: ecma
|
|
|
|
|
|
feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.
Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.
Specifically:
* tree-sitter "standard capture names"
(https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72):
- `@parameter` -> `@variable.parameter`
- `@field` -> `@variable.member`
- `@namespace` -> `@module`
- `@float` -> `@number.float`
- `@symbol` -> `@string.special.symbol`
- `@string.regex` -> `@string.regexp`
- `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
- `@text.title` -> `@markup.heading`
- `@text.literal` -> `@markup.raw`
- `@text.reference` -> `@markup.link`
- `@text.uri` -> `@markup.link.url` (in markup links)
- `@string.special` -> `@markup.link.label` (non-url links)
- `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)
* Helix captures
(https://docs.helix-editor.com/master/themes.html#syntax-highlighting):
- `@method` -> `@function.method`
- `@method.call` -> `@function.method.call`
- `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
- `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
- `@text.uri` -> `@string.special.url` (outside markup)
- `@preproc` -> `@keyword.directive`
- `@define` -> `@keyword.directive`(`.define`?)
- `@storageclass` -> `@keyword.storage`
- `@conditional` -> `@keyword.conditional`
- `@debug` -> `@keyword.debug`
- `@exception` -> `@keyword.exception`
- `@include` -> `@keyword.import`
- `@repeat` -> `@keyword.repeat`
* cleanup
- remove some redundant `@conceal` (but still allow it for conceal-only patterns)
- remove obsolete `@error` (syntax linting is out of scope for this repo)
- sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
|
|
|
"pragma" @keyword.import
|
2022-07-12 17:10:08 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Annotations
|
2022-07-07 22:33:47 +08:00
|
|
|
(ui_annotation
|
|
|
|
|
"@" @operator
|
2024-03-21 20:44:35 +09:00
|
|
|
type_name: [
|
|
|
|
|
(identifier) @attribute
|
|
|
|
|
(nested_identifier
|
|
|
|
|
(identifier) @attribute)
|
|
|
|
|
])
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
; type
|
|
|
|
|
(ui_property
|
2022-07-07 22:33:47 +08:00
|
|
|
type: (type_identifier) @type)
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Properties
|
2022-07-07 22:33:47 +08:00
|
|
|
(ui_object_definition_binding
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(identifier) @property
|
|
|
|
|
(nested_identifier
|
|
|
|
|
(identifier) @property)
|
|
|
|
|
])
|
2022-07-07 22:33:47 +08:00
|
|
|
|
|
|
|
|
(ui_binding
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(identifier) @property
|
|
|
|
|
(nested_identifier
|
|
|
|
|
(identifier) @property)
|
|
|
|
|
])
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
; locals query appears not working unless id: <ref> isn't a parameter.
|
2022-07-07 22:33:47 +08:00
|
|
|
(ui_binding
|
|
|
|
|
name: (identifier) @property
|
|
|
|
|
(#eq? @property "id")
|
2024-03-21 20:44:35 +09:00
|
|
|
value: (expression_statement
|
|
|
|
|
(identifier) @variable))
|
2022-07-07 22:33:47 +08:00
|
|
|
|
|
|
|
|
(ui_property
|
|
|
|
|
name: (identifier) @property)
|
|
|
|
|
|
|
|
|
|
(ui_required
|
|
|
|
|
name: (identifier) @property)
|
|
|
|
|
|
|
|
|
|
(ui_list_property_type
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"<"
|
|
|
|
|
">"
|
|
|
|
|
] @punctuation.bracket)
|
2022-07-07 22:33:47 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Signals
|
2022-07-07 22:33:47 +08:00
|
|
|
(ui_signal
|
|
|
|
|
name: (identifier) @function)
|
|
|
|
|
|
|
|
|
|
(ui_signal_parameter
|
|
|
|
|
(identifier) @variable)
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; ui_object_definition
|
2022-07-07 22:33:47 +08:00
|
|
|
(ui_object_definition
|
2022-10-30 23:33:42 +02:00
|
|
|
type_name: (identifier) @type)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-07-07 22:33:47 +08:00
|
|
|
(ui_object_definition
|
2022-10-30 23:33:42 +02:00
|
|
|
type_name: (nested_identifier) @type)
|
2022-07-07 22:33:47 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; namespace
|
2022-07-12 17:10:08 +08:00
|
|
|
(nested_identifier
|
|
|
|
|
(nested_identifier
|
2024-01-06 15:05:50 +09:00
|
|
|
(identifier) @module))
|
2022-07-07 22:33:47 +08:00
|
|
|
|
|
|
|
|
; Tokens
|
|
|
|
|
;-------
|
2022-10-30 23:33:42 +02:00
|
|
|
[
|
|
|
|
|
"abstract"
|
|
|
|
|
"private"
|
|
|
|
|
"protected"
|
|
|
|
|
"public"
|
|
|
|
|
"default"
|
|
|
|
|
"readonly"
|
2022-07-07 22:33:47 +08:00
|
|
|
"required"
|
2024-03-08 19:09:51 +09:00
|
|
|
] @keyword.modifier
|
2022-07-07 22:33:47 +08:00
|
|
|
|
|
|
|
|
; from typescript
|
|
|
|
|
(type_identifier) @type
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-07-07 22:33:47 +08:00
|
|
|
(predefined_type) @type.builtin
|
|
|
|
|
|
|
|
|
|
(type_arguments
|
|
|
|
|
"<" @punctuation.bracket
|
|
|
|
|
">" @punctuation.bracket)
|
|
|
|
|
|
|
|
|
|
; Variables
|
2024-01-06 15:05:50 +09:00
|
|
|
(required_parameter
|
|
|
|
|
(identifier) @variable)
|
2022-07-07 22:33:47 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(optional_parameter
|
|
|
|
|
(identifier) @variable)
|
2022-07-07 22:33:47 +08:00
|
|
|
|
|
|
|
|
; Keywords
|
2022-10-30 23:33:42 +02:00
|
|
|
[
|
|
|
|
|
"on"
|
|
|
|
|
"property"
|
|
|
|
|
"signal"
|
2022-07-07 22:33:47 +08:00
|
|
|
"declare"
|
|
|
|
|
"implements"
|
|
|
|
|
"override"
|
|
|
|
|
] @keyword
|
2024-04-23 20:29:59 -07:00
|
|
|
|
2024-04-23 12:23:15 -07:00
|
|
|
[
|
|
|
|
|
"interface"
|
|
|
|
|
"type"
|
|
|
|
|
"enum"
|
|
|
|
|
"namespace"
|
|
|
|
|
] @keyword.type
|
|
|
|
|
|
2024-04-23 20:29:59 -07:00
|
|
|
"keyof" @keyword.operator
|