nvim-treesitter/queries/qmljs/highlights.scm
Christian Clason 1ae9b0e455 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"
  (3f44b89685/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`
2024-01-19 16:58:37 +01:00

153 lines
2.1 KiB
Scheme

; inherits: ecma
"pragma" @keyword.import
;;; Annotations
(ui_annotation
"@" @operator
type_name: [
(identifier) @attribute
(nested_identifier (identifier) @attribute)
])
;; type
(ui_property
type: (type_identifier) @type)
;;; Properties
(ui_object_definition_binding
name: [
(identifier) @property
(nested_identifier (identifier) @property)
])
(ui_binding
name: [
(identifier) @property
(nested_identifier (identifier) @property)
])
;; locals query appears not working unless id: <ref> isn't a parameter.
(ui_binding
name: (identifier) @property
(#eq? @property "id")
value: (expression_statement (identifier) @variable))
(ui_property
name: (identifier) @property)
(ui_required
name: (identifier) @property)
(ui_list_property_type
["<" ">"] @punctuation.bracket)
;;; Signals
(ui_signal
name: (identifier) @function)
(ui_signal_parameter
(identifier) @variable)
;;; ui_object_definition
(ui_object_definition
type_name: (identifier) @type)
(ui_object_definition
type_name: (nested_identifier) @type)
;;; namespace
(nested_identifier
(nested_identifier
(identifier) @module)
)
; Properties
;-----------
(property_identifier) @property
;;; function
(call_expression
function: (member_expression
object: (identifier) @variable
property:(property_identifier) @function
)
)
;;; js
; Literals
;---------
[
(true)
(false)
] @boolean
[
(null)
(undefined)
] @constant.builtin
(comment) @comment @spell
[
(string)
(template_string)
] @string
(regex) @string.regexp
(number) @number
; Tokens
;-------
[
"abstract"
"private"
"protected"
"public"
"default"
"readonly"
"required"
] @type.qualifier
; from typescript
(type_identifier) @type
(predefined_type) @type.builtin
((identifier) @type
(#lua-match? @type "^%u"))
(type_arguments
"<" @punctuation.bracket
">" @punctuation.bracket)
; Variables
(required_parameter (identifier) @variable)
(optional_parameter (identifier) @variable)
; Keywords
[
"on"
"property"
"signal"
"declare"
"enum"
"export"
"implements"
"interface"
"keyof"
"namespace"
"type"
"override"
] @keyword