aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--ftdetect/wgsl.vim1
-rw-r--r--lua/nvim-treesitter/parsers.lua9
-rw-r--r--queries/wgsl/folds.scm10
-rw-r--r--queries/wgsl/highlights.scm101
5 files changed, 122 insertions, 0 deletions
diff --git a/README.md b/README.md
index 510352ba2..df159b796 100644
--- a/README.md
+++ b/README.md
@@ -263,6 +263,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (experimental, maintained by @zegervdv)
- [x] [vim](https://github.com/vigoux/tree-sitter-viml) (maintained by @vigoux)
- [x] [vue](https://github.com/ikatyang/tree-sitter-vue) (maintained by @WhyNotHugo)
+- [x] [wgsl](https://github.com/szebniok/tree-sitter-wgsl) (maintained by @szebniok)
- [x] [yaml](https://github.com/ikatyang/tree-sitter-yaml) (maintained by @stsewd)
- [x] [yang](https://github.com/Hubro/tree-sitter-yang) (maintained by @Hubro)
- [x] [zig](https://github.com/maxxnino/tree-sitter-zig) (maintained by @maxxnino)
diff --git a/ftdetect/wgsl.vim b/ftdetect/wgsl.vim
new file mode 100644
index 000000000..bfd7ccae7
--- /dev/null
+++ b/ftdetect/wgsl.vim
@@ -0,0 +1 @@
+au BufRead,BufNewFile *.wgsl set filetype=wgsl
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 58c08c351..0b29dbee9 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -1025,6 +1025,15 @@ list.astro = {
maintainers = { "@virchau13" },
}
+list.wgsl = {
+ install_info = {
+ url = "https://github.com/szebniok/tree-sitter-wgsl",
+ files = { "src/parser.c" },
+ },
+ maintainers = { "@szebniok" },
+ filetype = "wgsl"
+}
+
local M = {
list = list,
filetype_to_parsername = filetype_to_parsername,
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