on master help sign in
Fix C++ syntax highlighting, and improve C & WGSL highlighting (#4079)
b4e795dChickenkeeper
languages.toml+2−2
@@ -184,7 +184,7 @@ args = { console = "internalConsole", attachCommands = [ "platform select remote
184
184
185[[grammar]]
185[[grammar]]
186name = "c"
186name = "c"
187−source = { git = "https://github.com/tree-sitter/tree-sitter-c", rev = "f05e279aedde06a25801c3f2b2cc8ac17fac52ae" }
187+source = { git = "https://github.com/tree-sitter/tree-sitter-c", rev = "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }
188
188
189[[language]]
189[[language]]
190name = "cpp"
190name = "cpp"
@@ -221,7 +221,7 @@ args = { console = "internalConsole", attachCommands = [ "platform select remote
221
221
222[[grammar]]
222[[grammar]]
223name = "cpp"
223name = "cpp"
224−source = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "e8dcc9d2b404c542fd236ea5f7208f90be8a6e89" }
224+source = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "d5e90fba898f320db48d81ddedd78d52c67c1fed" }
225
225
226[[language]]
226[[language]]
227name = "c-sharp"
227name = "c-sharp"
runtime/queries/c/highlights.scm+105−57
@@ -1,65 +1,104 @@
1−(storage_class_specifier) @keyword.storage
2−
3−"goto" @keyword
4−"register" @keyword
5−"break" @keyword
6−"case" @keyword
7−"continue" @keyword
8−"default" @keyword
9−"do" @keyword
10−"else" @keyword
11−"enum" @keyword
12−"extern" @keyword
13−"for" @keyword
14−"if" @keyword
15−"inline" @keyword
16−"return" @keyword
17"sizeof" @keyword
1"sizeof" @keyword
18−"struct" @keyword
19−"switch" @keyword
20−"typedef" @keyword
21−"union" @keyword
22−"volatile" @keyword
23−"while" @keyword
24−"const" @keyword
25
2
26[
3[
4+ "enum"
5+ "struct"
6+ "typedef"
7+ "union"
8+] @keyword.storage.type
9+
10+[
11+ "const"
12+ "extern"
13+ "inline"
14+ "register"
15+ "volatile"
16+ (storage_class_specifier)
17+] @keyword.storage.modifier
18+
19+[
20+ "goto"
21+ "break"
22+ "continue"
23+] @keyword.control
24+
25+[
26+ "do"
27+ "for"
28+ "while"
29+] @keyword.control.repeat
30+
31+[
32+ "if"
33+ "else"
34+ "switch"
35+ "case"
36+ "default"
37+] @keyword.control.conditional
38+
39+"return" @keyword.control.return
40+
41+[
42+ "defined"
27− "#define"
43+ "#define"
28− "#elif"
44+ "#elif"
29− "#else"
45+ "#else"
30− "#endif"
46+ "#endif"
31− "#if"
47+ "#if"
32− "#ifdef"
48+ "#ifdef"
33− "#ifndef"
49+ "#ifndef"
34− "#include"
50+ "#include"
35− (preproc_directive)
51+ (preproc_directive)
36] @keyword.directive
52] @keyword.directive
37
53
38−"--" @operator
54+[
55+ "+"
39−"-" @operator
56+ "-"
40−"-=" @operator
41−"->" @operator
42−"=" @operator
43−"!=" @operator
44−"*" @operator
57+ "*"
45−"&" @operator
58+ "/"
46−"&&" @operator
47−"+" @operator
48−"++" @operator
59+ "++"
49−"+=" @operator
60+ "--"
50−"<" @operator
61+ "%"
51−"==" @operator
62+ "=="
63+ "!="
52−">" @operator
64+ ">"
53−"||" @operator
65+ "<"
54−">=" @operator
66+ ">="
67+ "<="
68+ "&&"
69+ "||"
70+ "!"
71+ "&"
72+ "|"
73+ "^"
74+ "~"
75+ "<<"
76+ ">>"
77+ "="
78+ "+="
79+ "-="
80+ "*="
81+ "/="
82+ "%="
83+ "<<="
84+ ">>="
85+ "&="
86+ "^="
87+ "|="
88+ "?"
55−"<=" @operator
89+] @operator
56−
90+
91+(conditional_expression ":" @operator)
92+
57−"." @punctuation.delimiter
93+"..." @punctuation
94+
58−";" @punctuation.delimiter
95+["," "." ":" ";" "->" "::"] @punctuation.delimiter
96+
97+["(" ")" "[" "]" "{" "}"] @punctuation.bracket
59
98
60[(true) (false)] @constant.builtin.boolean
99[(true) (false)] @constant.builtin.boolean
61
100
62−(enumerator) @type.enum.variant
101+(enumerator name: (identifier) @type.enum.variant)
63
102
64(string_literal) @string
103(string_literal) @string
65(system_lib_string) @string
104(system_lib_string) @string
@@ -73,19 +112,28 @@
73(call_expression
112(call_expression
74 function: (field_expression
113 function: (field_expression
75 field: (field_identifier) @function))
114 field: (field_identifier) @function))
115+(call_expression (argument_list (identifier) @variable))
76(function_declarator
116(function_declarator
77− declarator: (identifier) @function)
117+ declarator: [(identifier) (field_identifier)] @function)
118+(parameter_declaration
119+ declarator: (identifier) @variable.parameter)
120+(parameter_declaration
121+ (pointer_declarator
122+ declarator: (identifier) @variable.parameter))
78(preproc_function_def
123(preproc_function_def
79 name: (identifier) @function.special)
124 name: (identifier) @function.special)
80
125
126+(attribute
127+ name: (identifier) @attribute)
128+
81(field_identifier) @variable.other.member
129(field_identifier) @variable.other.member
82(statement_identifier) @label
130(statement_identifier) @label
83(type_identifier) @type
131(type_identifier) @type
84−(primitive_type) @type
132+(primitive_type) @type.builtin
85(sized_type_specifier) @type
133(sized_type_specifier) @type
86
134
87((identifier) @constant
135((identifier) @constant
88− (#match? @constant "^[A-Z][A-Z\\d_]*$"))
136+ (#match? @constant "^[A-Z][A-Z\\d_]*$"))
89
137
90(identifier) @variable
138(identifier) @variable
91
139
runtime/queries/cpp/highlights.scm+78−30
@@ -1,5 +1,3 @@
1−; inherits: c
2−
3; Functions
1; Functions
4
2
5(call_expression
3(call_expression
@@ -12,56 +10,106 @@
12(template_method
10(template_method
13 name: (field_identifier) @function)
11 name: (field_identifier) @function)
14
12
15−(template_function
16− name: (identifier) @function)
17−
18(function_declarator
13(function_declarator
19 declarator: (qualified_identifier
14 declarator: (qualified_identifier
20 name: (identifier) @function))
15 name: (identifier) @function))
21
16
22(function_declarator
17(function_declarator
23 declarator: (qualified_identifier
18 declarator: (qualified_identifier
19+ name: (qualified_identifier
24− name: (identifier) @function))
20+ name: (identifier) @function)))
25
21
26(function_declarator
22(function_declarator
27 declarator: (field_identifier) @function)
23 declarator: (field_identifier) @function)
28
24
29; Types
25; Types
30
26
27+(using_declaration ("using" "namespace" (identifier) @namespace))
28+(using_declaration ("using" "namespace" (qualified_identifier name: (identifier) @namespace)))
29+(namespace_definition name: (identifier) @namespace)
31−((namespace_identifier) @type
30+(namespace_identifier) @namespace
32− (#match? @type "^[A-Z]"))
31+
32+(qualified_identifier name: (identifier) @type.enum.variant)
33
33
34(auto) @type
34(auto) @type
35+"decltype" @type
35
36
36; Constants
37; Constants
37
38
38(this) @variable.builtin
39(this) @variable.builtin
39−(nullptr) @constant
40+(nullptr) @constant.builtin
40
41
41; Keywords
42; Keywords
42
43
44+(template_argument_list (["<" ">"] @punctuation.bracket))
45+(template_parameter_list (["<" ">"] @punctuation.bracket))
46+(default_method_clause "default" @keyword)
47+
48+"static_assert" @function.special
49+
50+[
51+ "<=>"
52+ "[]"
53+ "()"
54+] @operator
55+
56+[
57+ "co_await"
58+ "co_return"
59+ "co_yield"
60+ "concept"
61+ "delete"
62+ "final"
63+ "new"
64+ "operator"
65+ "requires"
66+ "using"
67+] @keyword
68+
69+[
43−"catch" @keyword
70+ "catch"
71+ "noexcept"
72+ "throw"
73+ "try"
74+] @keyword.control.exception
75+
76+
77+[
78+ "and"
79+ "and_eq"
80+ "bitor"
81+ "bitand"
82+ "not"
83+ "not_eq"
84+ "or"
85+ "or_eq"
86+ "xor"
87+ "xor_eq"
88+] @keyword.operator
89+
90+[
44−"class" @keyword
91+ "class"
92+ "namespace"
93+ "typename"
94+] @keyword.storage.type
95+
96+[
45−"constexpr" @keyword
97+ "constexpr"
46−"delete" @keyword
98+ "constinit"
99+ "consteval"
47−"explicit" @keyword
100+ "explicit"
48−"final" @keyword
49−"friend" @keyword
101+ "friend"
50−"mutable" @keyword
102+ "mutable"
51−"namespace" @keyword
52−"noexcept" @keyword
53−"new" @keyword
54−"override" @keyword
55−"private" @keyword
103+ "private"
56−"protected" @keyword
104+ "protected"
57−"public" @keyword
105+ "public"
106+ "override"
58−"template" @keyword
107+ "template"
59−"throw" @keyword
60−"try" @keyword
61−"typename" @keyword
62−"using" @keyword
63−"virtual" @keyword
108+ "virtual"
109+] @keyword.storage.modifier
64
110
65; Strings
111; Strings
66
112
67(raw_string_literal) @string
113(raw_string_literal) @string
114+
115+; inherits: c
runtime/queries/wgsl/highlights.scm+89−86
@@ -2,57 +2,26 @@
2(float_literal) @constant.numeric.float
2(float_literal) @constant.numeric.float
3(bool_literal) @constant.builtin.boolean
3(bool_literal) @constant.builtin.boolean
4
4
5−(global_constant_declaration) @variable
5+[
6−(global_variable_declaration) @variable
6+ "bitcast"
7−(compound_statement) @variable
7+ "discard"
8−(const_expression) @function
8+ "enable"
9−
9+ "fallthrough"
10−(variable_identifier_declaration
10+] @keyword
11− (identifier) @variable
12− (type_declaration) @type)
13−
14−(function_declaration
15− (identifier) @function
16− (function_return_type_declaration
17− (type_declaration) @type))
18−
19−(parameter
20− (variable_identifier_declaration
21− (identifier) @variable.parameter
22− (type_declaration) @type))
23−
24−(struct_declaration
25− (identifier) @type)
26−
27−(struct_declaration
28− (struct_member
29− (variable_identifier_declaration
30− (identifier) @variable.other.member
31− (type_declaration) @type)))
32
11
33−(type_constructor_or_function_call_expression
12+[
34− (type_declaration) @function)
13+ "let"
14+ "override"
15+ "struct"
16+ "type"
17+ "var"
18+ (texel_format)
19+] @keyword.storage.type
35
20
36[
21[
37− "struct"
22+ (access_mode)
38− "bitcast"
23+ (address_space)
39− "discard"
40− "enable"
41− "fallthrough"
42− "fn"
43− "let"
44− "private"
45− "read"
46− "read_write"
47− "storage"
48− "type"
49− "uniform"
50− "var"
51− "workgroup"
52− "write"
53− "override"
54− (texel_format)
55−] @keyword
24+] @keyword.storage.modifier
56
25
57"fn" @keyword.function
26"fn" @keyword.function
58
27
@@ -62,53 +31,87 @@
62
31
63["(" ")" "[" "]" "{" "}"] @punctuation.bracket
32["(" ")" "[" "]" "{" "}"] @punctuation.bracket
64
33
34+(type_declaration ["<" ">"] @punctuation.bracket)
35+
65[
36[
66− "loop"
67− "for"
68− "while"
69− "break"
37+ "break"
70− "continue"
38+ "continue"
71− "continuing"
39+ "continuing"
40+] @keyword.control
41+
42+[
43+ "loop"
44+ "for"
45+ "while"
72] @keyword.control.repeat
46] @keyword.control.repeat
73
47
74[
48[
75− "if"
49+ "if"
76− "else"
50+ "else"
77− "switch"
51+ "switch"
78− "case"
52+ "case"
79− "default"
53+ "default"
80] @keyword.control.conditional
54] @keyword.control.conditional
81
55
82[
56[
57+ "!"
58+ "!="
59+ "%"
60+ "%="
83− "&"
61+ "&"
84− "&&"
62+ "&&"
63+ "&="
64+ "*"
65+ "*="
66+ "+"
67+ "++"
68+ "+="
69+ "-"
70+ "--"
71+ "-="
72+ "->"
85− "/"
73+ "/"
86− "!"
74+ "/="
75+ "<"
76+ "<<"
77+ "<="
87− "="
78+ "="
88− "=="
79+ "=="
89− "!="
90− ">"
80+ ">"
91− ">="
81+ ">="
92− ">>"
82+ ">>"
93− "<"
94− "<="
95− "<<"
96− "%"
83+ "@"
97− "-"
84+ "^"
98− "+"
85+ "^="
99− "|"
86+ "|"
87+ "|="
100− "||"
88+ "||"
101− "*"
102− "~"
89+ "~"
103− "^"
104− "@"
105− "++"
106− "--"
107] @operator
90] @operator
108
91
92+(function_declaration
93+ (identifier) @function)
94+
95+(parameter
96+ (variable_identifier_declaration
97+ (identifier) @variable.parameter))
98+
99+(struct_declaration
100+ (identifier) @type)
101+
102+(struct_declaration
103+ (struct_member
104+ (variable_identifier_declaration
105+ (identifier) @variable.other.member)))
106+
107+(type_constructor_or_function_call_expression
108+ (type_declaration (identifier) @function))
109+
110+(type_declaration _ @type)
111+
109(attribute
112(attribute
110− (identifier) @attribute)
113+ (identifier) @attribute)
111
114
112−(comment) @comment
115+(identifier) @variable
113
116
114−(ERROR) @error
117+(comment) @comment