-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Copy pathcpp-highlights.scm
155 lines (129 loc) · 2.58 KB
/
cpp-highlights.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
; Downloaded and combined from these:
; https://github.com/tree-sitter/tree-sitter-c/blob/3aa2995549d5d8b26928e8d3fa2770fd4327414e/queries/highlights.scm
; https://github.com/tree-sitter/tree-sitter-cpp/blob/f41b4f66a42100be405f96bdc4ebc4a61095d3e8/queries/highlights.scm
; Functions
(identifier) @variable
((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
"break" @keyword
"case" @keyword
"const" @keyword
"continue" @keyword
"default" @keyword
"do" @keyword
"else" @keyword
"enum" @keyword
"extern" @keyword
"for" @keyword
"if" @keyword
"inline" @keyword
"return" @keyword
"sizeof" @keyword
"static" @keyword
"struct" @keyword
"switch" @keyword
"typedef" @keyword
"union" @keyword
"volatile" @keyword
"while" @keyword
"#define" @keyword
"#elif" @keyword
"#else" @keyword
"#endif" @keyword
"#if" @keyword
"#ifdef" @keyword
"#ifndef" @keyword
"#include" @keyword
(preproc_directive) @keyword
"--" @operator
"-" @operator
"-=" @operator
"->" @operator
"=" @operator
"!=" @operator
"*" @operator
"&" @operator
"&&" @operator
"+" @operator
"++" @operator
"+=" @operator
"<" @operator
"==" @operator
">" @operator
"||" @operator
"." @delimiter
";" @delimiter
(string_literal) @string
(system_lib_string) @string
(null) @constant
(number_literal) @number
(char_literal) @number
(field_identifier) @property
(statement_identifier) @label
(type_identifier) @type
(primitive_type) @type
(sized_type_specifier) @type
(call_expression
function: (identifier) @function)
(call_expression
function: (field_expression
field: (field_identifier) @function))
(function_declarator
declarator: (identifier) @function)
(preproc_function_def
name: (identifier) @function.special)
(comment) @comment
(call_expression
function: (qualified_identifier
name: (identifier) @function))
(template_function
name: (identifier) @function)
(template_method
name: (field_identifier) @function)
(template_function
name: (identifier) @function)
(function_declarator
declarator: (qualified_identifier
name: (identifier) @function))
(function_declarator
declarator: (field_identifier) @function)
; Types
((namespace_identifier) @type
(#match? @type "^[A-Z]"))
(auto) @type
; Constants
(this) @variable.builtin
(null "nullptr" @constant)
; Keywords
[
"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"
"concept"
"requires"
"virtual"
] @keyword
; Strings
(raw_string_literal) @string