Unnamed repository; edit this file 'description' to name the repository.
Add queries for Wgsl (#14257)
Erasin Wang 6 months ago
parent da4ede9 · commit e5e7fe4
-rw-r--r--book/src/generated/lang-support.md2
-rw-r--r--runtime/queries/wgsl/indents.scm6
-rw-r--r--runtime/queries/wgsl/rainbows.scm14
-rw-r--r--runtime/queries/wgsl/tags.scm10
-rw-r--r--runtime/queries/wgsl/textobjects.scm14
5 files changed, 45 insertions, 1 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 7beb4713..c6c77af7 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -279,7 +279,7 @@
| webc | ✓ | | | | | |
| werk | ✓ | | | | | |
| wesl | ✓ | ✓ | | | | |
-| wgsl | ✓ | | | | | `wgsl-analyzer` |
+| wgsl | ✓ | ✓ | ✓ | ✓ | ✓ | `wgsl-analyzer` |
| wit | ✓ | | ✓ | | | |
| wren | ✓ | ✓ | ✓ | | | |
| xit | ✓ | | | | | |
diff --git a/runtime/queries/wgsl/indents.scm b/runtime/queries/wgsl/indents.scm
new file mode 100644
index 00000000..ef65973a
--- /dev/null
+++ b/runtime/queries/wgsl/indents.scm
@@ -0,0 +1,6 @@
+[
+ (struct_declaration)
+ (compound_statement)
+] @indent
+
+"}" @outdent
diff --git a/runtime/queries/wgsl/rainbows.scm b/runtime/queries/wgsl/rainbows.scm
new file mode 100644
index 00000000..6e644e36
--- /dev/null
+++ b/runtime/queries/wgsl/rainbows.scm
@@ -0,0 +1,14 @@
+[
+ (struct_declaration)
+ (function_declaration)
+ (attribute)
+ (type_declaration)
+ (compound_statement)
+ (argument_list_expression)
+ (postfix_expression)
+ (variable_qualifier)
+ (subscript_expression)
+ (parenthesized_expression)
+] @rainbow.scope
+
+["(" ")" "[" "]" "{" "}" "<" ">"] @rainbow.bracket
diff --git a/runtime/queries/wgsl/tags.scm b/runtime/queries/wgsl/tags.scm
new file mode 100644
index 00000000..ae640b4b
--- /dev/null
+++ b/runtime/queries/wgsl/tags.scm
@@ -0,0 +1,10 @@
+(struct_declaration
+ name: (identifier) @definition.struct)
+
+(function_declaration
+ name: (identifier) @definition.function)
+
+(global_variable_declaration
+ (variable_declaration
+ (variable_identifier_declaration
+ name: (identifier) @definition.constant)))
diff --git a/runtime/queries/wgsl/textobjects.scm b/runtime/queries/wgsl/textobjects.scm
new file mode 100644
index 00000000..4dade474
--- /dev/null
+++ b/runtime/queries/wgsl/textobjects.scm
@@ -0,0 +1,14 @@
+(function_declaration
+ body: (_) @function.inside) @function.around
+
+(struct_declaration) @class.around
+
+[
+ (struct_member)
+ (parameter)
+ (variable_declaration)
+] @parameter.around
+
+(comment) @comment.inside
+
+(comment)+ @comment.around