aboutsummaryrefslogtreecommitdiffstats
path: root/queries/wgsl
diff options
context:
space:
mode:
authorKonrad Bochnia <kbochnia@gmail.com>2022-04-11 18:14:04 +0200
committerStephan Seitz <stephan.seitz@fau.de>2022-04-11 23:16:19 +0200
commit1a58c71b73bdd0a0b71ad3738555b11e21c60dc6 (patch)
tree71705e6b70183e66a2e791acbfa00f811932dfe5 /queries/wgsl
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-1a58c71b73bdd0a0b71ad3738555b11e21c60dc6.tar
nvim-treesitter-1a58c71b73bdd0a0b71ad3738555b11e21c60dc6.tar.gz
nvim-treesitter-1a58c71b73bdd0a0b71ad3738555b11e21c60dc6.tar.bz2
nvim-treesitter-1a58c71b73bdd0a0b71ad3738555b11e21c60dc6.tar.lz
nvim-treesitter-1a58c71b73bdd0a0b71ad3738555b11e21c60dc6.tar.xz
nvim-treesitter-1a58c71b73bdd0a0b71ad3738555b11e21c60dc6.tar.zst
nvim-treesitter-1a58c71b73bdd0a0b71ad3738555b11e21c60dc6.zip
Add WGSL parser
Diffstat (limited to 'queries/wgsl')
-rw-r--r--queries/wgsl/folds.scm10
-rw-r--r--queries/wgsl/highlights.scm101
2 files changed, 111 insertions, 0 deletions
diff --git a/queries/wgsl/folds.scm b/queries/wgsl/folds.scm
new file mode 100644
index 000000000..d8000edee
--- /dev/null
+++ b/queries/wgsl/folds.scm
@@ -0,0 +1,10 @@
+[
+ (struct_declaration)
+ (function_declaration)
+ (if_statement)
+ (switch_statement)
+ (switch_body)
+ (loop_statement)
+ (for_statement)
+ (while_statement)
+] @fold
diff --git a/queries/wgsl/highlights.scm b/queries/wgsl/highlights.scm
new file mode 100644
index 000000000..9f9696e10
--- /dev/null
+++ b/queries/wgsl/highlights.scm
@@ -0,0 +1,101 @@
+(identifier) @variable
+(int_literal) @number
+(float_literal) @float
+(bool_literal) @boolean
+
+(type_declaration) @type
+
+(function_declaration
+ (identifier) @function)
+
+(parameter
+ (variable_identifier_declaration (identifier) @parameter))
+
+(struct_declaration
+ (identifier) @structure)
+
+(struct_declaration
+ (struct_member (variable_identifier_declaration (identifier) @field)))
+
+(type_constructor_or_function_call_expression
+ (type_declaration) @function)
+
+[
+ "struct"
+ "bitcast"
+ "discard"
+ "enable"
+ "fallthrough"
+ "fn"
+ "let"
+ "private"
+ "read"
+ "read_write"
+ "storage"
+ "type"
+ "uniform"
+ "var"
+ "workgroup"
+ "write"
+ "override"
+ (texel_format)
+] @keyword
+
+"fn" @keyword.function
+
+"return" @keyword.return
+
+[ "," "." ":" ";" ] @punctuation.delimiter
+
+["(" ")" "[" "]" "{" "}"] @punctuation.bracket
+
+[
+ "loop"
+ "for"
+ "while"
+ "break"
+ "continue"
+ "continuing"
+] @repeat
+
+[
+ "if"
+ "else"
+ "switch"
+ "case"
+ "default"
+] @conditional
+
+[
+ "&"
+ "&&"
+ "/"
+ "!"
+ "="
+ "=="
+ "!="
+ ">"
+ ">="
+ ">>"
+ "<"
+ "<="
+ "<<"
+ "%"
+ "-"
+ "+"
+ "|"
+ "||"
+ "*"
+ "~"
+ "^"
+ "@"
+ "++"
+ "--"
+] @operator
+
+(attribute
+ (identifier) @attribute)
+
+(comment) @comment
+
+(ERROR) @error