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

Fix C++ syntax highlighting, and improve C & WGSL highlighting #4079

Merged
merged 28 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c31cb5b
Update languages.toml
Chickenkeeper Oct 2, 2022
2f5dd93
Update highlights.scm
Chickenkeeper Oct 2, 2022
4f311c3
Update highlights.scm
Chickenkeeper Oct 2, 2022
5ef73b7
Update highlights.scm
Chickenkeeper Oct 2, 2022
5aaf2c0
Update highlights.scm
Chickenkeeper Oct 4, 2022
46e8092
Update highlights.scm
Chickenkeeper Oct 4, 2022
ad050d9
Update highlights.scm
Chickenkeeper Oct 4, 2022
0ea971b
Update highlights.scm
Chickenkeeper Oct 5, 2022
d342649
Update highlights.scm
Chickenkeeper Oct 5, 2022
1502d0a
Update highlights.scm
Chickenkeeper Oct 5, 2022
b9d0523
Moved inherit to the bottom
Chickenkeeper Oct 5, 2022
cb40b60
Removed unnecessary highlights and comments
Chickenkeeper Oct 5, 2022
6278800
Another update to tree-sitter-cpp
Chickenkeeper Oct 5, 2022
36e0e47
Added attribute highlight
Chickenkeeper Oct 6, 2022
798e196
Added extra operators
Chickenkeeper Oct 6, 2022
bc9206f
Fixed enumerator stanza
Chickenkeeper Oct 10, 2022
beb6e92
Update highlights.scm
Chickenkeeper Oct 10, 2022
fef05aa
Rearranged keywords and operators
Chickenkeeper Oct 12, 2022
8a83962
Rearranged keywords and added more highlights
Chickenkeeper Oct 12, 2022
b116770
Changed `auto` key back to @type
Chickenkeeper Oct 12, 2022
e97f5ec
changed `decltype` key to `@type`
Chickenkeeper Oct 12, 2022
d736fb5
Changed `break` key to `@keyword.control`
Chickenkeeper Oct 12, 2022
f78d635
Changed `continue` & `continuing` keys to `@keyword.control`
Chickenkeeper Oct 12, 2022
852bb9e
Use `@operator` for `:` in conditional expressions
Chickenkeeper Oct 13, 2022
1338e5e
Added `@punctuation.bracket` key for angle brackets in type declarations
Chickenkeeper Oct 13, 2022
372a52b
Improved variable & type highlighting
Chickenkeeper Oct 13, 2022
132211a
Removed unneccesary nested `type_declaration`
Chickenkeeper Oct 13, 2022
f91afcd
Rearranged code to prevent modifiers leaking, and coloured constructo…
Chickenkeeper Oct 13, 2022
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: 2 additions & 2 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ args = { console = "internalConsole", attachCommands = [ "platform select remote

[[grammar]]
name = "c"
source = { git = "https://github.com/tree-sitter/tree-sitter-c", rev = "f05e279aedde06a25801c3f2b2cc8ac17fac52ae" }
source = { git = "https://github.com/tree-sitter/tree-sitter-c", rev = "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }

[[language]]
name = "cpp"
Expand Down Expand Up @@ -221,7 +221,7 @@ args = { console = "internalConsole", attachCommands = [ "platform select remote

[[grammar]]
name = "cpp"
source = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "e8dcc9d2b404c542fd236ea5f7208f90be8a6e89" }
source = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "f40125503642845492d87fa56ece3ed26a4ef4db" }

[[language]]
name = "c-sharp"
Expand Down
129 changes: 73 additions & 56 deletions runtime/queries/c/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,61 +1,75 @@
(storage_class_specifier) @keyword.storage

"goto" @keyword
"register" @keyword
"break" @keyword
"case" @keyword
"continue" @keyword
"default" @keyword
"do" @keyword
"else" @keyword
"enum" @keyword
"extern" @keyword
"for" @keyword
"if" @keyword
"inline" @keyword
"return" @keyword
"sizeof" @keyword
"struct" @keyword
"switch" @keyword
"typedef" @keyword
"union" @keyword
"volatile" @keyword
"while" @keyword
"const" @keyword
[
"register"
"const"
"enum"
"extern"
"inline"
"sizeof"
"struct"
"typedef"
Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved
"union"
"volatile"
] @keyword

[
"for"
"do"
"while"
"break"
Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved
"continue"
] @keyword.control.repeat

[
"goto"
Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved
"if"
"else"
"switch"
"case"
"default"
Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved
] @keyword.control.conditional

"return" @keyword.control.return

[
"#define"
"#elif"
"#else"
"#endif"
"#if"
"#ifdef"
"#ifndef"
"#include"
(preproc_directive)
"defined"
"#define"
"#elif"
"#else"
"#endif"
"#if"
"#ifdef"
"#ifndef"
"#include"
(preproc_directive)
] @keyword.directive

"--" @operator
"-" @operator
"-=" @operator
"->" @operator
"=" @operator
"!=" @operator
"*" @operator
"&" @operator
"&&" @operator
"+" @operator
"++" @operator
"+=" @operator
"<" @operator
"==" @operator
">" @operator
"||" @operator
">=" @operator
"<=" @operator

"." @punctuation.delimiter
";" @punctuation.delimiter
[
"--"
"-"
"-="
"->"
"="
"!="
"*"
"&"
"&&"
"+"
"++"
"+="
"<"
"=="
">"
"||"
">="
"<="
"::"
] @operator

["," "." ":" ";"] @punctuation.delimiter
Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved

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

[(true) (false)] @constant.builtin.boolean

Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -73,20 +87,23 @@
(call_expression
function: (field_expression
field: (field_identifier) @function))
(function_declarator) @function
Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved
(function_declarator
declarator: (identifier) @function)
parameters: (parameter_list) @variable.parameter)
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
(preproc_function_def
name: (identifier) @function.special)

(compound_statement) @variable
(init_declarator) @variable
Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved
(field_identifier) @variable.other.member
(statement_identifier) @label
(struct_specifier) @type
(type_definition) @type
(type_identifier) @type
(primitive_type) @type
(primitive_type) @type.builtin
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
(sized_type_specifier) @type

((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))

(identifier) @variable

(comment) @comment
62 changes: 31 additions & 31 deletions runtime/queries/cpp/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
(template_method
name: (field_identifier) @function)

(template_function
name: (identifier) @function)
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved

(function_declarator
declarator: (qualified_identifier
name: (identifier) @function))
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved

(function_declarator
declarator: (qualified_identifier
name: (identifier) @function))
Expand All @@ -28,9 +21,7 @@

; Types

((namespace_identifier) @type
(#match? @type "^[A-Z]"))

(namespace_identifier) @namespace
Chickenkeeper marked this conversation as resolved.
Show resolved Hide resolved
(auto) @type

; Constants
Expand All @@ -40,27 +31,36 @@

; Keywords

"catch" @keyword
"class" @keyword
"constexpr" @keyword
"delete" @keyword
"explicit" @keyword
"final" @keyword
"friend" @keyword
"mutable" @keyword
"namespace" @keyword
"noexcept" @keyword
"new" @keyword
"override" @keyword
"private" @keyword
"protected" @keyword
"public" @keyword
"template" @keyword
"throw" @keyword
"try" @keyword
"typename" @keyword
"using" @keyword
"virtual" @keyword
[
"catch"
"class"
"co_await"
"co_return"
"co_yield"
"constexpr"
"constinit"
"consteval"
"delete"
"explicit"
"final"
"friend"
"mutable"
"namespace"
"noexcept"
"new"
"override"
"private"
"protected"
"public"
"template"
"throw"
"try"
"typename"
"using"
"virtual"
"concept"
"requires"
] @keyword

; Strings

Expand Down
2 changes: 0 additions & 2 deletions runtime/queries/wgsl/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,3 @@
(identifier) @attribute)

(comment) @comment

(ERROR) @error