2024-08-29 22:37:17 -04:00
|
|
|
; Variables
|
|
|
|
|
(identifier) @variable
|
2023-03-02 08:06:35 -05:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Parameters
|
|
|
|
|
(parameter
|
|
|
|
|
name: (identifier) @variable.parameter)
|
2021-11-21 14:42:32 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(payload
|
|
|
|
|
(identifier) @variable.parameter)
|
2024-01-20 18:47:56 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Types
|
|
|
|
|
(parameter
|
|
|
|
|
type: (identifier) @type)
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
((identifier) @type
|
|
|
|
|
(#lua-match? @type "^[A-Z_][a-zA-Z0-9_]*"))
|
2021-08-24 13:39:52 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(variable_declaration
|
|
|
|
|
(identifier) @type
|
|
|
|
|
"="
|
|
|
|
|
[
|
|
|
|
|
(struct_declaration)
|
|
|
|
|
(enum_declaration)
|
|
|
|
|
(union_declaration)
|
|
|
|
|
(opaque_declaration)
|
|
|
|
|
])
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
[
|
|
|
|
|
(builtin_type)
|
|
|
|
|
"anyframe"
|
|
|
|
|
] @type.builtin
|
2024-01-20 18:47:56 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Constants
|
|
|
|
|
((identifier) @constant
|
|
|
|
|
(#lua-match? @constant "^[A-Z][A-Z_0-9]+$"))
|
2024-01-20 18:47:56 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
[
|
|
|
|
|
"null"
|
|
|
|
|
"unreachable"
|
|
|
|
|
"undefined"
|
|
|
|
|
] @constant.builtin
|
2024-01-20 18:47:56 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(field_expression
|
|
|
|
|
.
|
|
|
|
|
member: (identifier) @constant)
|
2021-08-08 18:54:24 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(enum_declaration
|
|
|
|
|
(container_field
|
|
|
|
|
type: (identifier) @constant))
|
2021-11-25 20:42:01 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Labels
|
|
|
|
|
(block_label
|
|
|
|
|
(identifier) @label)
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(break_label
|
|
|
|
|
(identifier) @label)
|
2024-01-20 18:47:56 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Fields
|
|
|
|
|
(field_initializer
|
|
|
|
|
.
|
|
|
|
|
(identifier) @variable.member)
|
2021-08-13 13:36:01 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(field_expression
|
|
|
|
|
(_)
|
|
|
|
|
member: (identifier) @variable.member)
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(container_field
|
|
|
|
|
name: (identifier) @variable.member)
|
2021-03-30 19:53:03 +02:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(initializer_list
|
|
|
|
|
(assignment_expression
|
|
|
|
|
left: (field_expression
|
|
|
|
|
.
|
|
|
|
|
member: (identifier) @variable.member)))
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Functions
|
|
|
|
|
(builtin_identifier) @function.builtin
|
2021-03-30 19:53:03 +02:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(call_expression
|
|
|
|
|
function: (identifier) @function.call)
|
2023-02-24 06:38:47 -05:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(call_expression
|
|
|
|
|
function: (field_expression
|
|
|
|
|
member: (identifier) @function.call))
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(function_declaration
|
|
|
|
|
name: (identifier) @function)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Modules
|
|
|
|
|
(variable_declaration
|
|
|
|
|
(identifier) @module
|
|
|
|
|
(builtin_function
|
|
|
|
|
(builtin_identifier) @keyword.import
|
|
|
|
|
(#any-of? @keyword.import "@import" "@cImport")))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Builtins
|
|
|
|
|
[
|
|
|
|
|
"c"
|
|
|
|
|
"..."
|
|
|
|
|
] @variable.builtin
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
((identifier) @variable.builtin
|
|
|
|
|
(#eq? @variable.builtin "_"))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(calling_convention
|
|
|
|
|
(identifier) @variable.builtin)
|
2022-10-28 16:57:38 +03:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Keywords
|
2022-10-28 16:57:38 +03:00
|
|
|
[
|
2023-02-13 10:20:02 +11:00
|
|
|
"asm"
|
|
|
|
|
"defer"
|
|
|
|
|
"errdefer"
|
|
|
|
|
"test"
|
2023-02-24 06:38:47 -05:00
|
|
|
"error"
|
2024-05-12 14:33:12 -07:00
|
|
|
"const"
|
|
|
|
|
"var"
|
2023-02-13 10:20:02 +11:00
|
|
|
] @keyword
|
2021-08-08 18:54:24 +09:00
|
|
|
|
2024-04-23 12:23:15 -07:00
|
|
|
[
|
|
|
|
|
"struct"
|
|
|
|
|
"union"
|
|
|
|
|
"enum"
|
2024-08-29 22:37:17 -04:00
|
|
|
"opaque"
|
2024-04-23 12:23:15 -07:00
|
|
|
] @keyword.type
|
|
|
|
|
|
2023-02-24 06:37:45 -05:00
|
|
|
[
|
|
|
|
|
"async"
|
|
|
|
|
"await"
|
|
|
|
|
"suspend"
|
|
|
|
|
"nosuspend"
|
|
|
|
|
"resume"
|
|
|
|
|
] @keyword.coroutine
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
"fn" @keyword.function
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2021-07-08 22:28:51 +02:00
|
|
|
[
|
2023-02-13 10:20:02 +11:00
|
|
|
"and"
|
|
|
|
|
"or"
|
|
|
|
|
"orelse"
|
|
|
|
|
] @keyword.operator
|
2021-07-08 22:28:51 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
"return" @keyword.return
|
2021-03-23 06:18:43 +05:30
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"if"
|
2023-02-13 10:20:02 +11:00
|
|
|
"else"
|
2021-03-23 06:18:43 +05:30
|
|
|
"switch"
|
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.conditional
|
2021-03-23 06:18:43 +05:30
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"for"
|
|
|
|
|
"while"
|
2023-02-14 08:52:45 +11:00
|
|
|
"break"
|
|
|
|
|
"continue"
|
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.repeat
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2024-05-12 18:00:55 -07:00
|
|
|
[
|
|
|
|
|
"usingnamespace"
|
|
|
|
|
"export"
|
|
|
|
|
] @keyword.import
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2022-10-28 16:57:38 +03:00
|
|
|
[
|
2023-02-13 10:20:02 +11:00
|
|
|
"try"
|
|
|
|
|
"catch"
|
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.exception
|
2022-10-28 16:57:38 +03:00
|
|
|
|
2021-08-08 18:54:24 +09:00
|
|
|
[
|
2023-02-13 10:20:02 +11:00
|
|
|
"volatile"
|
|
|
|
|
"allowzero"
|
|
|
|
|
"noalias"
|
|
|
|
|
"addrspace"
|
|
|
|
|
"align"
|
|
|
|
|
"callconv"
|
|
|
|
|
"linksection"
|
2024-05-12 14:33:12 -07:00
|
|
|
"pub"
|
|
|
|
|
"inline"
|
|
|
|
|
"noinline"
|
|
|
|
|
"extern"
|
2023-02-13 10:20:02 +11:00
|
|
|
"comptime"
|
|
|
|
|
"packed"
|
|
|
|
|
"threadlocal"
|
2024-08-29 22:37:17 -04:00
|
|
|
] @keyword.modifier
|
2021-08-08 18:54:24 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Operator
|
2021-08-08 18:54:24 +09:00
|
|
|
[
|
2024-07-22 20:19:23 -07:00
|
|
|
"="
|
2024-08-29 22:37:17 -04:00
|
|
|
"*="
|
|
|
|
|
"*%="
|
|
|
|
|
"*|="
|
|
|
|
|
"/="
|
|
|
|
|
"%="
|
|
|
|
|
"+="
|
|
|
|
|
"+%="
|
|
|
|
|
"+|="
|
|
|
|
|
"-="
|
|
|
|
|
"-%="
|
|
|
|
|
"-|="
|
|
|
|
|
"<<="
|
|
|
|
|
"<<|="
|
|
|
|
|
">>="
|
|
|
|
|
"&="
|
|
|
|
|
"^="
|
|
|
|
|
"|="
|
|
|
|
|
"!"
|
|
|
|
|
"~"
|
|
|
|
|
"-"
|
|
|
|
|
"-%"
|
|
|
|
|
"&"
|
|
|
|
|
"=="
|
|
|
|
|
"!="
|
|
|
|
|
">"
|
|
|
|
|
">="
|
|
|
|
|
"<="
|
|
|
|
|
"<"
|
|
|
|
|
"^"
|
|
|
|
|
"|"
|
|
|
|
|
"<<"
|
|
|
|
|
">>"
|
|
|
|
|
"<<|"
|
|
|
|
|
"+"
|
|
|
|
|
"++"
|
|
|
|
|
"+%"
|
|
|
|
|
"+|"
|
|
|
|
|
"-|"
|
2021-08-13 13:36:01 +09:00
|
|
|
"*"
|
2024-08-29 22:37:17 -04:00
|
|
|
"/"
|
|
|
|
|
"%"
|
2021-08-13 13:36:01 +09:00
|
|
|
"**"
|
2024-08-29 22:37:17 -04:00
|
|
|
"*%"
|
|
|
|
|
"*|"
|
|
|
|
|
"||"
|
2021-08-13 13:36:01 +09:00
|
|
|
".*"
|
2024-08-29 22:37:17 -04:00
|
|
|
".?"
|
2021-09-20 17:58:15 +09:00
|
|
|
"?"
|
2024-08-29 22:37:17 -04:00
|
|
|
".."
|
2021-03-23 06:18:43 +05:30
|
|
|
] @operator
|
|
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Literals
|
|
|
|
|
(character) @character
|
2021-03-23 06:18:43 +05:30
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
([
|
|
|
|
|
(string)
|
|
|
|
|
(multiline_string)
|
|
|
|
|
] @string
|
|
|
|
|
(#set! "priority" 95))
|
2021-08-13 13:36:01 +09:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(integer) @number
|
|
|
|
|
|
|
|
|
|
(float) @number.float
|
|
|
|
|
|
|
|
|
|
(boolean) @boolean
|
|
|
|
|
|
|
|
|
|
(escape_sequence) @string.escape
|
|
|
|
|
|
|
|
|
|
; Punctuation
|
2021-08-08 18:54:24 +09:00
|
|
|
[
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @punctuation.bracket
|
2024-05-12 14:33:12 -07:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
[
|
|
|
|
|
";"
|
|
|
|
|
"."
|
|
|
|
|
","
|
|
|
|
|
":"
|
|
|
|
|
"=>"
|
|
|
|
|
"->"
|
|
|
|
|
] @punctuation.delimiter
|
2024-05-12 14:33:12 -07:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
(payload
|
2024-05-12 14:33:12 -07:00
|
|
|
"|" @punctuation.bracket)
|
|
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
; Comments
|
|
|
|
|
(comment) @comment @spell
|
2024-07-22 20:19:23 -07:00
|
|
|
|
2024-08-29 22:37:17 -04:00
|
|
|
((comment) @comment.documentation
|
|
|
|
|
(#lua-match? @comment.documentation "^//!"))
|