aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirawi2021-11-27 02:19:40 +0000
committerGitHub2021-11-27 02:19:40 +0000
commit4ec20eaeffa6144f01ae8d5a95b12ea1593f3080 (patch)
tree8fc2aea5d8e543e31d1d0c40552a4fa3d1c2a9c8
parent6e62c3de47ff14df394c1c17fec103c134aa045c (diff)
Add language support for WGSL (#1166)
-rw-r--r--.gitmodules4
m---------helix-syntax/languages/tree-sitter-wgsl0
-rw-r--r--languages.toml8
-rw-r--r--runtime/queries/wgsl/highlights.scm102
4 files changed, 114 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
index bf596bdc..039a3ee3 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -142,3 +142,7 @@
path = helix-syntax/languages/tree-sitter-perl
url = https://github.com/ganezdragon/tree-sitter-perl
shallow = true
+[submodule "helix-syntax/languages/tree-sitter-wgsl"]
+ path = helix-syntax/languages/tree-sitter-wgsl
+ url = https://github.com/szebniok/tree-sitter-wgsl
+ shallow = true
diff --git a/helix-syntax/languages/tree-sitter-wgsl b/helix-syntax/languages/tree-sitter-wgsl
new file mode 160000
+Subproject f00ff52251edbd58f4d39c9c3204383253032c1
diff --git a/languages.toml b/languages.toml
index 5326f917..5dcbd872 100644
--- a/languages.toml
+++ b/languages.toml
@@ -405,3 +405,11 @@ file-types = ["rkt"]
shebangs = ["racket"]
comment-token = ";"
language-server = { command = "racket", args = ["-l", "racket-langserver"] }
+
+[[language]]
+name = "wgsl"
+scope = "source.wgsl"
+file-types = ["wgsl"]
+roots = []
+comment-token = "//"
+indent = { tab-width = 4, unit = " " }
diff --git a/runtime/queries/wgsl/highlights.scm b/runtime/queries/wgsl/highlights.scm
new file mode 100644
index 00000000..7fbc87d8
--- /dev/null
+++ b/runtime/queries/wgsl/highlights.scm
@@ -0,0 +1,102 @@
+(const_literal) @constant.numeric
+
+(type_declaration) @type
+
+(function_declaration
+ (identifier) @function)
+
+(struct_declaration
+ (identifier) @type)
+
+(type_constructor_or_function_call_expression
+ (type_declaration) @function)
+
+(parameter
+ (variable_identifier_declaration (identifier) @variable.parameter))
+
+[
+ "struct"
+ "bitcast"
+ ; "block"
+ "discard"
+ "enable"
+ "fallthrough"
+ "fn"
+ "let"
+ "private"
+ "read"
+ "read_write"
+ "return"
+ "storage"
+ "type"
+ "uniform"
+ "var"
+ "workgroup"
+ "write"
+ (texel_format)
+] @keyword ; TODO reserved keywords
+
+[
+ (true)
+ (false)
+] @constant.builtin.boolean
+
+[ "," "." ":" ";" ] @punctuation.delimiter
+
+;; brackets
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "loop"
+ "for"
+ "break"
+ "continue"
+ "continuing"
+] @keyword.control.repeat
+
+[
+ "if"
+ "else"
+ "elseif"
+ "switch"
+ "case"
+ "default"
+] @keyword.control.conditional
+
+[
+ "&"
+ "&&"
+ "/"
+ "!"
+ "="
+ "=="
+ "!="
+ ">"
+ ">="
+ ">>"
+ "<"
+ "<="
+ "<<"
+ "%"
+ "-"
+ "+"
+ "|"
+ "||"
+ "*"
+ "~"
+ "^"
+] @operator
+
+(attribute
+ (identifier) @variable.other.member)
+
+(comment) @comment
+
+(ERROR) @error