nvim-treesitter/runtime/queries/zig/highlights.scm

282 lines
3.3 KiB
Scheme
Raw Normal View History

; Variables
(identifier) @variable
; Parameters
(parameter
name: (identifier) @variable.parameter)
(payload
(identifier) @variable.parameter)
; Types
(parameter
type: (identifier) @type)
2021-03-23 06:18:43 +05:30
((identifier) @type
(#lua-match? @type "^[A-Z_][a-zA-Z0-9_]*"))
(variable_declaration
(identifier) @type
"="
[
(struct_declaration)
(enum_declaration)
(union_declaration)
(opaque_declaration)
])
2024-01-06 15:05:50 +09:00
[
(builtin_type)
"anyframe"
] @type.builtin
; Constants
((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z_0-9]+$"))
[
"null"
"unreachable"
"undefined"
] @constant.builtin
(field_expression
.
member: (identifier) @constant)
2021-08-08 18:54:24 +09:00
(enum_declaration
(container_field
type: (identifier) @constant))
2021-11-25 20:42:01 +09:00
; Labels
(block_label
(identifier) @label)
2021-03-23 06:18:43 +05:30
(break_label
(identifier) @label)
; Fields
(field_initializer
.
(identifier) @variable.member)
(field_expression
(_)
member: (identifier) @variable.member)
2021-03-23 06:18:43 +05:30
(container_field
name: (identifier) @variable.member)
(initializer_list
(assignment_expression
left: (field_expression
.
member: (identifier) @variable.member)))
2021-03-23 06:18:43 +05:30
; Functions
(builtin_identifier) @function.builtin
(call_expression
function: (identifier) @function.call)
(call_expression
function: (field_expression
member: (identifier) @function.call))
2021-03-23 06:18:43 +05:30
(function_declaration
name: (identifier) @function)
2024-01-06 15:05:50 +09: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
; Builtins
[
"c"
"..."
] @variable.builtin
2021-03-23 06:18:43 +05:30
((identifier) @variable.builtin
(#eq? @variable.builtin "_"))
2024-01-06 15:05:50 +09:00
(calling_convention
(identifier) @variable.builtin)
2022-10-28 16:57:38 +03:00
; Keywords
2022-10-28 16:57:38 +03:00
[
"asm"
"defer"
"errdefer"
"test"
"error"
2024-05-12 14:33:12 -07:00
"const"
"var"
] @keyword
2021-08-08 18:54:24 +09:00
2024-04-23 12:23:15 -07:00
[
"struct"
"union"
"enum"
"opaque"
2024-04-23 12:23:15 -07:00
] @keyword.type
[
"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
[
"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"
"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"
"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
[
"usingnamespace"
"export"
] @keyword.import
2021-03-23 06:18:43 +05:30
2022-10-28 16:57:38 +03: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
[
"volatile"
"allowzero"
"noalias"
"addrspace"
"align"
"callconv"
"linksection"
2024-05-12 14:33:12 -07:00
"pub"
"inline"
"noinline"
"extern"
"comptime"
"packed"
"threadlocal"
] @keyword.modifier
2021-08-08 18:54:24 +09:00
; Operator
2021-08-08 18:54:24 +09:00
[
2024-07-22 20:19:23 -07:00
"="
"*="
"*%="
"*|="
"/="
"%="
"+="
"+%="
"+|="
"-="
"-%="
"-|="
"<<="
"<<|="
">>="
"&="
"^="
"|="
"!"
"~"
"-"
"-%"
"&"
"=="
"!="
">"
">="
"<="
"<"
"^"
"|"
"<<"
">>"
"<<|"
"+"
"++"
"+%"
"+|"
"-|"
"*"
"/"
"%"
"**"
"*%"
"*|"
"||"
".*"
".?"
"?"
".."
2021-03-23 06:18:43 +05:30
] @operator
; Literals
(character) @character
2021-03-23 06:18:43 +05:30
([
(string)
(multiline_string)
] @string
(#set! "priority" 95))
(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
[
";"
"."
","
":"
"=>"
"->"
] @punctuation.delimiter
2024-05-12 14:33:12 -07:00
(payload
2024-05-12 14:33:12 -07:00
"|" @punctuation.bracket)
; Comments
(comment) @comment @spell
2024-07-22 20:19:23 -07:00
((comment) @comment.documentation
(#lua-match? @comment.documentation "^//!"))