Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language support for WGSL #1166

Merged
merged 1 commit into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions helix-syntax/languages/tree-sitter-wgsl
Submodule tree-sitter-wgsl added at f00ff5
8 changes: 8 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = " " }
102 changes: 102 additions & 0 deletions runtime/queries/wgsl/highlights.scm
Original file line number Diff line number Diff line change
@@ -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