Debian Codegraph @

runtime/queries/wesl/highlights.scm

raw symbols SCIP
1 ; reserved: must not be used in source code. https://www.w3.org/TR/WGSL/#reserved-words
2
3 ; ((identifier) @special
4 ; (#any-of? @special
5 ; "NULL" "Self" "abstract" "active" "alignas" "alignof" "as" "asm"
6 ; "asm_fragment" "async" "attribute" "auto" "await" "become" "binding_array"
7 ; "cast" "catch" "class" "co_await" "co_return" "co_yield" "coherent"
8 ; "column_major" "common" "compile" "compile_fragment" "concept" "const_cast"
9 ; "consteval" "constexpr" "constinit" "crate" "debugger" "decltype" "delete"
10 ; "demote" "demote_to_helper" "do" "dynamic_cast" "enum" "explicit" "export"
11 ; "extends" "extern" "external" "fallthrough" "filter" "final" "finally" "friend"
12 ; "from" "fxgroup" "get" "goto" "groupshared" "highp" "impl" "implements" "import"
13 ; "inline" "instanceof" "interface" "layout" "lowp" "macro" "macro_rules" "match"
14 ; "mediump" "meta" "mod" "module" "move" "mut" "mutable" "namespace" "new"
15 ; "nil" "noexcept" "noinline" "nointerpolation" "non_coherent" "noncoherent"
16 ; "noperspective" "null" "nullptr" "of" "operator" "package" "packoffset"
17 ; "partition" "pass" "patch" "pixelfragment" "precise" "precision" "premerge"
18 ; "priv" "protected" "pub" "public" "readonly" "ref" "regardless" "register"
19 ; "reinterpret_cast" "require" "resource" "restrict" "self" "set" "shared"
20 ; "sizeof" "smooth" "snorm" "static" "static_assert" "static_cast" "std"
21 ; "subroutine" "super" "target" "template" "this" "thread_local" "throw" "trait"
22 ; "try" "type" "typedef" "typeid" "typename" "typeof" "union" "unless" "unorm"
23 ; "unsafe" "unsized" "use" "using" "varying" "virtual" "volatile" "wgsl" "where"
24 ; "with" "writeonly" "yield"))
25
26 ; comments
27
28 (line_comment) @comment.line
29 (block_comment) @comment.block
30
31 ; Base catch-all: every specific identifier rule below overrides it.
32 (identifier) @variable
33
34 ; imports (WESL extension)
35
36 (import_item (identifier) @type
37 (#match? @type "^[A-Z]"))
38
39 (import_item (identifier) @constant
40 (#match? @constant "^[A-Z0-9_]+$"))
41
42 (import_item (identifier) @namespace)
43
44 (import_path (identifier) @namespace)
45
46 (ident_path (identifier) @namespace)
47
48 ; types
49
50 ((identifier) @constant
51 (#match? @constant "^[A-Z0-9_]+$"))
52
53 ((identifier) @type
54 (#match? @type "^[A-Z]"))
55
56 (type_specifier
57 (identifier) @type)
58
59 ; functions
60
61 (function_decl
62 (function_header
63 (identifier) @function))
64
65 (call_expression
66 (identifier) @function)
67
68 ; templates
69
70 (template_list) @punctuation
71
72 (variable_decl ; this is var<storage> et.al
73 (template_list
74 (identifier) @keyword.storage.modifier))
75
76 (type_specifier
77 (template_list
78 (identifier) @type))
79
80 (template_list
81 (template_list
82 (identifier) @type))
83
84 ; attributes
85
86 (attribute
87 (identifier) @attribute) @attribute
88
89 (attribute
90 (identifier) @attr-name
91 (argument_list
92 (identifier) @variable.builtin)
93 (#eq? @attr-name "builtin"))
94
95 ; variables, names
96
97 (param
98 (identifier) @variable.parameter)
99 (variable_decl
100 (identifier) @variable)
101 (const_assert_statement) @variable
102
103 (struct_decl
104 (identifier) @type)
105
106 (struct_member
107 name: (_) @variable.other.member)
108
109 (named_component_expression
110 component: (_) @variable.other.member)
111
112 ; literals
113
114 (bool_literal) @constant.builtin.boolean
115 (int_literal) @constant.numeric.integer
116 (float_literal) @constant.numeric.float
117
118
119 ; keywords
120
121 [
122 "if"
123 "else"
124 ] @keyword.control.conditional
125 [
126 "loop"
127 "for"
128 "while"
129 "break"
130 "continue"
131 ] @keyword.control.repeat
132 [
133 "return"
134 ] @keyword.control.return
135 [
136 "switch"
137 "case"
138 "default"
139 "discard"
140 ] @keyword.control
141 [ ; WESL import extension
142 "import"
143 "as"
144 ] @keyword.control.import
145 [
146 "fn"
147 ] @keyword.function
148 [
149 "var"
150 "let"
151 "const"
152 "struct"
153 ] @keyword.storage.type
154 [
155 "alias"
156 "virtual" ; Bevy / naga_oil extension
157 "override" ; Bevy / naga_oil extension
158 ] @keyword
159
160 ; expressions
161
162 [
163 "-" "!" "~" "*" "&" ; unary
164 "^" "|" "/" "%" "+" (shift_left) (shift_right) ; binary
165 (less_than) (greater_than) (less_than_equal) (greater_than_equal) "==" "!=" ; relational
166 "+=" "-=" "*=" "/=" "%=" "|=" "^=" "++" "--" "=" ; assign
167 "->" ; return
168 ] @operator
169
170 ; punctuation
171
172 [ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
173 [ "," "." ":" ";" ] @punctuation.delimiter
174
175 ; preprocessor
176
177 [ (preproc_directive) "#import" ] @keyword.directive