2024-10-13 04:52:54 -04:00
|
|
|
; inherits: c
|
|
|
|
|
|
|
|
|
|
; cpp
|
|
|
|
|
((identifier) @variable.member
|
|
|
|
|
(#lua-match? @variable.member "^m_.*$"))
|
|
|
|
|
|
|
|
|
|
(parameter_declaration
|
|
|
|
|
declarator: (reference_declarator) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
; function(Foo ...foo)
|
|
|
|
|
(variadic_parameter_declaration
|
|
|
|
|
declarator: (variadic_declarator
|
|
|
|
|
(_) @variable.parameter))
|
|
|
|
|
|
|
|
|
|
; int foo = 0
|
|
|
|
|
(optional_parameter_declaration
|
|
|
|
|
declarator: (_) @variable.parameter)
|
|
|
|
|
|
|
|
|
|
;(field_expression) @variable.parameter ;; How to highlight this?
|
|
|
|
|
((field_expression
|
|
|
|
|
(field_identifier) @function.method) @_parent
|
|
|
|
|
(#has-parent? @_parent template_method function_declarator))
|
|
|
|
|
|
|
|
|
|
(field_declaration
|
|
|
|
|
(field_identifier) @variable.member)
|
|
|
|
|
|
|
|
|
|
(field_initializer
|
|
|
|
|
(field_identifier) @property)
|
|
|
|
|
|
|
|
|
|
(function_declarator
|
|
|
|
|
declarator: (field_identifier) @function.method)
|
|
|
|
|
|
|
|
|
|
(concept_definition
|
|
|
|
|
name: (identifier) @type.definition)
|
|
|
|
|
|
|
|
|
|
(alias_declaration
|
|
|
|
|
name: (type_identifier) @type.definition)
|
|
|
|
|
|
|
|
|
|
(namespace_identifier) @module
|
|
|
|
|
|
|
|
|
|
((namespace_identifier) @type
|
|
|
|
|
(#lua-match? @type "^[%u]"))
|
|
|
|
|
|
|
|
|
|
(case_statement
|
|
|
|
|
value: (qualified_identifier
|
|
|
|
|
(identifier) @constant))
|
|
|
|
|
|
|
|
|
|
(using_declaration
|
|
|
|
|
.
|
|
|
|
|
"using"
|
|
|
|
|
.
|
|
|
|
|
"namespace"
|
|
|
|
|
.
|
|
|
|
|
[
|
|
|
|
|
(qualified_identifier)
|
|
|
|
|
(identifier)
|
|
|
|
|
] @module)
|
|
|
|
|
|
|
|
|
|
(destructor_name
|
|
|
|
|
(identifier) @function.method)
|
|
|
|
|
|
|
|
|
|
; functions
|
|
|
|
|
(function_declarator
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @function))
|
|
|
|
|
|
|
|
|
|
(function_declarator
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @function)))
|
|
|
|
|
|
|
|
|
|
(function_declarator
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @function))))
|
|
|
|
|
|
|
|
|
|
((qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @function)))) @_parent
|
|
|
|
|
(#has-ancestor? @_parent function_declarator))
|
|
|
|
|
|
|
|
|
|
(function_declarator
|
|
|
|
|
(template_function
|
|
|
|
|
(identifier) @function))
|
|
|
|
|
|
|
|
|
|
(operator_name) @function
|
|
|
|
|
|
|
|
|
|
"operator" @function
|
|
|
|
|
|
|
|
|
|
"static_assert" @function.builtin
|
|
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @function.call))
|
|
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @function.call)))
|
|
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @function.call))))
|
|
|
|
|
|
|
|
|
|
((qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @function.call)))) @_parent
|
|
|
|
|
(#has-ancestor? @_parent call_expression))
|
|
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
|
(template_function
|
|
|
|
|
(identifier) @function.call))
|
|
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(template_function
|
|
|
|
|
(identifier) @function.call)))
|
|
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(template_function
|
|
|
|
|
(identifier) @function.call))))
|
|
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(template_function
|
|
|
|
|
(identifier) @function.call)))))
|
|
|
|
|
|
|
|
|
|
((qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(template_function
|
|
|
|
|
(identifier) @function.call))))) @_parent
|
|
|
|
|
(#has-ancestor? @_parent call_expression))
|
|
|
|
|
|
|
|
|
|
; methods
|
|
|
|
|
(function_declarator
|
|
|
|
|
(template_method
|
|
|
|
|
(field_identifier) @function.method))
|
|
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
|
(field_expression
|
|
|
|
|
(field_identifier) @function.method.call))
|
|
|
|
|
|
|
|
|
|
; constructors
|
|
|
|
|
((function_declarator
|
|
|
|
|
(qualified_identifier
|
|
|
|
|
(identifier) @constructor))
|
|
|
|
|
(#lua-match? @constructor "^%u"))
|
|
|
|
|
|
|
|
|
|
((call_expression
|
|
|
|
|
function: (identifier) @constructor)
|
|
|
|
|
(#lua-match? @constructor "^%u"))
|
|
|
|
|
|
|
|
|
|
((call_expression
|
|
|
|
|
function: (qualified_identifier
|
|
|
|
|
name: (identifier) @constructor))
|
|
|
|
|
(#lua-match? @constructor "^%u"))
|
|
|
|
|
|
|
|
|
|
((call_expression
|
|
|
|
|
function: (field_expression
|
|
|
|
|
field: (field_identifier) @constructor))
|
|
|
|
|
(#lua-match? @constructor "^%u"))
|
|
|
|
|
|
|
|
|
|
; constructing a type in an initializer list: Constructor (): **SuperType (1)**
|
|
|
|
|
((field_initializer
|
|
|
|
|
(field_identifier) @constructor
|
|
|
|
|
(argument_list))
|
|
|
|
|
(#lua-match? @constructor "^%u"))
|
|
|
|
|
|
|
|
|
|
; Constants
|
|
|
|
|
(this) @variable.builtin
|
|
|
|
|
|
|
|
|
|
(null
|
|
|
|
|
"nullptr" @constant.builtin)
|
|
|
|
|
|
|
|
|
|
(true) @boolean
|
|
|
|
|
|
|
|
|
|
(false) @boolean
|
|
|
|
|
|
|
|
|
|
; Literals
|
|
|
|
|
(raw_string_literal) @string
|
|
|
|
|
|
|
|
|
|
; Keywords
|
|
|
|
|
[
|
|
|
|
|
"try"
|
|
|
|
|
"catch"
|
|
|
|
|
"noexcept"
|
|
|
|
|
"throw"
|
|
|
|
|
] @keyword.exception
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"decltype"
|
|
|
|
|
"explicit"
|
|
|
|
|
"friend"
|
|
|
|
|
"override"
|
|
|
|
|
"using"
|
|
|
|
|
"requires"
|
|
|
|
|
"constexpr"
|
|
|
|
|
] @keyword
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"class"
|
|
|
|
|
"namespace"
|
|
|
|
|
"template"
|
|
|
|
|
"typename"
|
|
|
|
|
"concept"
|
|
|
|
|
] @keyword.type
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"co_await"
|
|
|
|
|
"co_yield"
|
|
|
|
|
"co_return"
|
|
|
|
|
] @keyword.coroutine
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"public"
|
|
|
|
|
"private"
|
|
|
|
|
"protected"
|
|
|
|
|
"final"
|
|
|
|
|
"virtual"
|
|
|
|
|
] @keyword.modifier
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"new"
|
|
|
|
|
"delete"
|
|
|
|
|
"xor"
|
|
|
|
|
"bitand"
|
|
|
|
|
"bitor"
|
|
|
|
|
"compl"
|
|
|
|
|
"not"
|
|
|
|
|
"xor_eq"
|
|
|
|
|
"and_eq"
|
|
|
|
|
"or_eq"
|
|
|
|
|
"not_eq"
|
|
|
|
|
"and"
|
|
|
|
|
"or"
|
|
|
|
|
] @keyword.operator
|
|
|
|
|
|
|
|
|
|
"<=>" @operator
|
|
|
|
|
|
|
|
|
|
"::" @punctuation.delimiter
|
|
|
|
|
|
|
|
|
|
(template_argument_list
|
|
|
|
|
[
|
|
|
|
|
"<"
|
|
|
|
|
">"
|
|
|
|
|
] @punctuation.bracket)
|
|
|
|
|
|
|
|
|
|
(template_parameter_list
|
|
|
|
|
[
|
|
|
|
|
"<"
|
|
|
|
|
">"
|
|
|
|
|
] @punctuation.bracket)
|
|
|
|
|
|
|
|
|
|
(literal_suffix) @operator
|
|
|
|
|
|
|
|
|
|
; hlsl
|
|
|
|
|
[
|
|
|
|
|
"in"
|
|
|
|
|
"out"
|
|
|
|
|
"inout"
|
|
|
|
|
"uniform"
|
|
|
|
|
"shared"
|
|
|
|
|
"groupshared"
|
|
|
|
|
"discard"
|
|
|
|
|
"cbuffer"
|
|
|
|
|
"row_major"
|
|
|
|
|
"column_major"
|
|
|
|
|
"globallycoherent"
|
|
|
|
|
"centroid"
|
|
|
|
|
"noperspective"
|
|
|
|
|
"nointerpolation"
|
|
|
|
|
"sample"
|
|
|
|
|
"linear"
|
|
|
|
|
"snorm"
|
|
|
|
|
"unorm"
|
|
|
|
|
"point"
|
|
|
|
|
"line"
|
|
|
|
|
"triangleadj"
|
|
|
|
|
"lineadj"
|
|
|
|
|
"triangle"
|
|
|
|
|
] @keyword.modifier
|
|
|
|
|
|
|
|
|
|
((identifier) @variable.builtin
|
|
|
|
|
(#lua-match? @variable.builtin "^SV_"))
|
|
|
|
|
|
|
|
|
|
(hlsl_attribute) @attribute
|
|
|
|
|
|
|
|
|
|
(hlsl_attribute
|
|
|
|
|
[
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
] @attribute)
|
2024-02-19 00:00:07 +09:00
|
|
|
|
2023-11-18 20:52:31 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"var"
|
|
|
|
|
"let"
|
|
|
|
|
"This"
|
2023-11-18 20:52:31 +01:00
|
|
|
] @type.builtin
|
|
|
|
|
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"interface"
|
|
|
|
|
"extension"
|
|
|
|
|
"property"
|
2024-02-16 00:42:42 +01:00
|
|
|
"associatedtype"
|
2024-02-21 01:23:02 +01:00
|
|
|
"where"
|
2024-01-06 15:05:50 +09:00
|
|
|
] @keyword
|
2023-11-18 20:52:31 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
"__init" @constructor
|
2023-11-18 20:52:31 +01:00
|
|
|
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"__subscript"
|
|
|
|
|
"get"
|
|
|
|
|
"set"
|
2023-11-18 20:52:31 +01:00
|
|
|
] @function.builtin
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(interface_requirements
|
|
|
|
|
(identifier) @type)
|
2023-11-18 20:52:31 +01:00
|
|
|
|
|
|
|
|
(binary_expression
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"is"
|
|
|
|
|
"as"
|
|
|
|
|
]
|
2023-11-18 20:52:31 +01:00
|
|
|
right: (identifier) @type)
|
|
|
|
|
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"as"
|
|
|
|
|
"is"
|
2023-11-18 20:52:31 +01:00
|
|
|
] @keyword.operator
|
|
|
|
|
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"__exported"
|
|
|
|
|
"import"
|
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
|
|
|
] @keyword.import
|
2023-11-18 20:52:31 +01:00
|
|
|
|
|
|
|
|
(property_declaration
|
|
|
|
|
(identifier) @property)
|