BlueGit

ict rusty-teams

Files

rusty-teams / vendor / gpui-component / src / highlighter / languages / rust / highlights.scm

highlights.scm

highlights.scm 3.4 KiB Download Raw
1; Identifiers
2
3(type_identifier) @type
4(primitive_type) @type.builtin
5(field_identifier) @property
6
7; Identifier conventions
8
9; Assume all-caps names are constants
10((identifier) @constant
11 (#match? @constant "^[A-Z][A-Z\\d_]+$"))
12
13; Assume uppercase names are enum constructors
14((identifier) @constructor
15 (#match? @constructor "^[A-Z]"))
16
17; Assume that uppercase names in paths are types
18((scoped_identifier
19 path: (identifier) @type)
20 (#match? @type "^[A-Z]"))
21((scoped_identifier
22 path: (scoped_identifier
23 name: (identifier) @type))
24 (#match? @type "^[A-Z]"))
25((scoped_type_identifier
26 path: (identifier) @type)
27 (#match? @type "^[A-Z]"))
28((scoped_type_identifier
29 path: (scoped_identifier
30 name: (identifier) @type))
31 (#match? @type "^[A-Z]"))
32
33; Assume all qualified names in struct patterns are enum constructors. (They're
34; either that, or struct names; highlighting both as constructors seems to be
35; the less glaring choice of error, visually.)
36(struct_pattern
37 type: (scoped_type_identifier
38 name: (type_identifier) @constructor))
39
40; Function calls
41
42(call_expression
43 function: (identifier) @function)
44(call_expression
45 function: (field_expression
46 field: (field_identifier) @function.method))
47(call_expression
48 function: (scoped_identifier
49 "::"
50 name: (identifier) @function))
51
52(generic_function
53 function: (identifier) @function)
54(generic_function
55 function: (scoped_identifier
56 name: (identifier) @function))
57(generic_function
58 function: (field_expression
59 field: (field_identifier) @function.method))
60
61(macro_invocation
62 macro: (identifier) @function.macro
63 "!" @function.macro)
64
65; Function definitions
66
67(function_item (identifier) @function)
68(function_signature_item (identifier) @function)
69
70[
71 (line_comment)
72 (block_comment)
73] @comment
74
75[
76 (line_comment (doc_comment))
77 (block_comment (doc_comment))
78] @comment.doc
79
80"(" @punctuation.bracket
81")" @punctuation.bracket
82"[" @punctuation.bracket
83"]" @punctuation.bracket
84"{" @punctuation.bracket
85"}" @punctuation.bracket
86
87(type_arguments
88 "<" @punctuation.bracket
89 ">" @punctuation.bracket)
90(type_parameters
91 "<" @punctuation.bracket
92 ">" @punctuation.bracket)
93
94"::" @punctuation.delimiter
95":" @punctuation.delimiter
96"." @punctuation.delimiter
97"," @punctuation.delimiter
98";" @punctuation.delimiter
99
100(parameter (identifier) @variable.parameter)
101
102(lifetime (identifier) @label)
103
104"as" @keyword
105"async" @keyword
106"await" @keyword
107"break" @keyword
108"const" @keyword
109"continue" @keyword
110"default" @keyword
111"dyn" @keyword
112"else" @keyword
113"enum" @keyword
114"extern" @keyword
115"fn" @keyword
116"for" @keyword
117"gen" @keyword
118"if" @keyword
119"impl" @keyword
120"in" @keyword
121"let" @keyword
122"loop" @keyword
123"macro_rules!" @keyword
124"match" @keyword
125"mod" @keyword
126"move" @keyword
127"pub" @keyword
128"raw" @keyword
129"ref" @keyword
130"return" @keyword
131"static" @keyword
132"struct" @keyword
133"trait" @keyword
134"type" @keyword
135"union" @keyword
136"unsafe" @keyword
137"use" @keyword
138"where" @keyword
139"while" @keyword
140"yield" @keyword
141(crate) @keyword
142(mutable_specifier) @keyword
143(use_list (self) @keyword)
144(scoped_use_list (self) @keyword)
145(scoped_identifier (self) @keyword)
146(super) @keyword
147
148(self) @variable.builtin
149
150(char_literal) @string
151(string_literal) @string
152(raw_string_literal) @string
153
154(boolean_literal) @constant.builtin
155(integer_literal) @constant.builtin
156(float_literal) @constant.builtin
157
158(escape_sequence) @escape
159
160(attribute_item) @attribute
161(inner_attribute_item) @attribute
162
163"*" @operator
164"&" @operator
165"'" @operator