on master help sign in
c/c++ highlighting: various tweaks
aef37d4Sam McCall
runtime/queries/c/highlights.scm+3−5
@@ -8,11 +8,9 @@
8] @keyword.storage.type
8] @keyword.storage.type
9
9
10[
10[
11− "const"
12 "extern"
11 "extern"
13− "inline"
14 "register"
12 "register"
15− "volatile"
13+ (type_qualifier)
16 (storage_class_specifier)
14 (storage_class_specifier)
17] @keyword.storage.modifier
15] @keyword.storage.modifier
18
16
@@ -107,7 +105,7 @@
107(system_lib_string) @string
105(system_lib_string) @string
108
106
109(null) @constant
107(null) @constant
110−(number_literal) @constant.numeric.integer
108+(number_literal) @constant.numeric
111(char_literal) @constant.character
109(char_literal) @constant.character
112
110
113(call_expression
111(call_expression
@@ -133,7 +131,7 @@
133(statement_identifier) @label
131(statement_identifier) @label
134(type_identifier) @type
132(type_identifier) @type
135(primitive_type) @type.builtin
133(primitive_type) @type.builtin
136−(sized_type_specifier) @type
134+(sized_type_specifier) @type.builtin
137
135
138((identifier) @constant
136((identifier) @constant
139 (#match? @constant "^[A-Z][A-Z\\d_]*$"))
137 (#match? @constant "^[A-Z][A-Z\\d_]*$"))
runtime/queries/cpp/highlights.scm+16−6
@@ -1,5 +1,11 @@
1; Functions
1; Functions
2
2
3+; These casts are parsed as function calls, but are not.
4+((identifier) @keyword (#eq? @keyword "static_cast"))
5+((identifier) @keyword (#eq? @keyword "dynamic_cast"))
6+((identifier) @keyword (#eq? @keyword "reinterpret_cast"))
7+((identifier) @keyword (#eq? @keyword "const_cast"))
8+
3(call_expression
9(call_expression
4 function: (qualified_identifier
10 function: (qualified_identifier
5 name: (identifier) @function))
11 name: (identifier) @function))
@@ -63,7 +69,6 @@
63 "co_yield"
69 "co_yield"
64 "concept"
70 "concept"
65 "delete"
71 "delete"
66− "final"
67 "new"
72 "new"
68 "operator"
73 "operator"
69 "requires"
74 "requires"
@@ -95,22 +100,27 @@
95 "class"
100 "class"
96 "namespace"
101 "namespace"
97 "typename"
102 "typename"
103+ "template"
98] @keyword.storage.type
104] @keyword.storage.type
99
105
100[
106[
101 "constexpr"
107 "constexpr"
102 "constinit"
108 "constinit"
103 "consteval"
109 "consteval"
110+ "mutable"
111+] @keyword.storage.modifier
112+
113+; Modifiers that aren't plausibly type/storage related.
114+[
104 "explicit"
115 "explicit"
105 "friend"
116 "friend"
106− "mutable"
117+ "virtual"
118+ (virtual_specifier) ; override/final
107 "private"
119 "private"
108 "protected"
120 "protected"
109 "public"
121 "public"
110− "override"
122+ "inline" ; C++ meaning differs from C!
111− "template"
112− "virtual"
113−] @keyword.storage.modifier
123+] @keyword
114
124
115; Strings
125; Strings
116
126