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

WGSL syntax highlighting fix #3996

Merged
merged 3 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "wgsl"
source = { git = "https://github.com/szebniok/tree-sitter-wgsl", rev = "f00ff52251edbd58f4d39c9c3204383253032c11" }
source = { git = "https://github.com/szebniok/tree-sitter-wgsl", rev = "272e89ef2aeac74178edb9db4a83c1ffef80a463" }

[[language]]
name = "llvm"
Expand Down
60 changes: 36 additions & 24 deletions runtime/queries/wgsl/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
(const_literal) @constant.numeric
(int_literal) @constant.numeric.integer
(float_literal) @constant.numeric.float
(bool_literal) @constant.builtin.boolean

(type_declaration) @type
(global_constant_declaration) @variable
(global_variable_declaration) @variable
(compound_statement) @variable
(const_expression) @function

(variable_identifier_declaration
(identifier) @variable
(type_declaration) @type)

(function_declaration
(identifier) @function)
(identifier) @function
(function_return_type_declaration
(type_declaration) @type))

(parameter
(variable_identifier_declaration
(identifier) @variable.parameter
(type_declaration) @type))

(struct_declaration
(identifier) @type)

(struct_declaration
(struct_member
(variable_identifier_declaration
(identifier) @variable.other.member
(type_declaration) @type)))

(type_constructor_or_function_call_expression
(type_declaration) @function)

(parameter
(variable_identifier_declaration (identifier) @variable.parameter))

[
"struct"
"bitcast"
; "block"
"discard"
"enable"
"fallthrough"
Expand All @@ -26,36 +44,28 @@
"private"
"read"
"read_write"
"return"
"storage"
"type"
"uniform"
"var"
"workgroup"
"write"
"override"
(texel_format)
] @keyword ; TODO reserved keywords
] @keyword

[
(true)
(false)
] @constant.builtin.boolean
"fn" @keyword.function

"return" @keyword.control.return

[ "," "." ":" ";" ] @punctuation.delimiter

;; brackets
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
["(" ")" "[" "]" "{" "}"] @punctuation.bracket

[
"loop"
"for"
"while"
"break"
"continue"
"continuing"
Expand All @@ -64,7 +74,6 @@
[
"if"
"else"
"elseif"
"switch"
"case"
"default"
Expand Down Expand Up @@ -92,10 +101,13 @@
"*"
"~"
"^"
"@"
"++"
"--"
] @operator

(attribute
(identifier) @variable.other.member)
(identifier) @attribute)

(comment) @comment

Expand Down