on master help sign in
Adjust highlighting for rust.
6e03019Blaž Hrastnik
TODO.md−5
@@ -1,5 +1,4 @@
1- Refactor tree-sitter-highlight to work like the atom one, recomputing partial tree updates.
1- Refactor tree-sitter-highlight to work like the atom one, recomputing partial tree updates.
2−- syntax errors highlight query
3
2
4------
3------
5
4
@@ -19,15 +18,11 @@
19- [ ] document.on_type provider triggers
18- [ ] document.on_type provider triggers
20- [ ] completion isIncomplete support
19- [ ] completion isIncomplete support
21
20
22−- [ ] extract indentation calculation queries so we can support other languages.
23−
241
211
25−- [ ] :format/:fmt that formats the buffer
26- [ ] respect view fullscreen flag
22- [ ] respect view fullscreen flag
27- [ ] Implement marks (superset of Selection/Range)
23- [ ] Implement marks (superset of Selection/Range)
28
24
29- [ ] nixos packaging
25- [ ] nixos packaging
30−- [ ] CI binary builds
31
26
32- [ ] = for auto indent line/selection
27- [ ] = for auto indent line/selection
33- [ ] :x for closing buffers
28- [ ] :x for closing buffers
runtime/queries/rust/highlights.scm+82−10
@@ -1,10 +1,28 @@
1; Identifier conventions
1; Identifier conventions
2
2
3+
3; Assume all-caps names are constants
4; Assume all-caps names are constants
4((identifier) @constant
5((identifier) @constant
5 (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
6 (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
6
7
8+; Assume other uppercase names are enum constructors
9+((identifier) @constructor
10+ (#match? @constructor "^[A-Z]"))
11+
7; Assume that uppercase names in paths are types
12; Assume that uppercase names in paths are types
13+(mod_item
14+ name: (identifier) @namespace)
15+(scoped_identifier
16+ path: (identifier) @namespace)
17+(scoped_identifier
18+ (scoped_identifier
19+ name: (identifier) @namespace))
20+(scoped_type_identifier
21+ path: (identifier) @namespace)
22+(scoped_type_identifier
23+ (scoped_identifier
24+ name: (identifier) @namespace))
25+
8((scoped_identifier
26((scoped_identifier
9 path: (identifier) @type)
27 path: (identifier) @type)
10 (#match? @type "^[A-Z]"))
28 (#match? @type "^[A-Z]"))
@@ -13,9 +31,15 @@
13 name: (identifier) @type))
31 name: (identifier) @type))
14 (#match? @type "^[A-Z]"))
32 (#match? @type "^[A-Z]"))
15
33
16−; Assume other uppercase names are enum constructors
34+; Namespaces
35+
36+(crate) @namespace
37+(scoped_use_list
38+ path: (identifier) @namespace)
39+(scoped_use_list
40+ path: (scoped_identifier
17−((identifier) @constructor
41+ (identifier) @namespace))
18− (#match? @constructor "^[A-Z]"))
42+(use_list (scoped_identifier (identifier) @namespace . (_)))
19
43
20; Function calls
44; Function calls
21
45
@@ -38,9 +62,19 @@
38 function: (field_expression
62 function: (field_expression
39 field: (field_identifier) @function.method))
63 field: (field_identifier) @function.method))
40
64
65+; (macro_invocation
66+; macro: (identifier) @function.macro
67+; "!" @function.macro)
68+(macro_invocation
69+ macro: (identifier) @function.macro)
41(macro_invocation
70(macro_invocation
71+ macro: (scoped_identifier
42− macro: (identifier) @function.macro
72+ (identifier) @function.macro .))
73+
74+; (metavariable) @variable
75+(metavariable) @function.macro
76+
43− "!" @function.macro)
77+"$" @function.macro
44
78
45; Function definitions
79; Function definitions
46
80
@@ -73,6 +107,7 @@
73";" @punctuation.delimiter
107";" @punctuation.delimiter
74
108
75(parameter (identifier) @variable.parameter)
109(parameter (identifier) @variable.parameter)
110+(closure_parameters (_) @variable.parameter)
76
111
77(lifetime (identifier) @label)
112(lifetime (identifier) @label)
78
113
@@ -114,9 +149,9 @@
114(scoped_use_list (self) @keyword)
149(scoped_use_list (self) @keyword)
115(scoped_identifier (self) @keyword)
150(scoped_identifier (self) @keyword)
116(super) @keyword
151(super) @keyword
152+"as" @keyword
117
153
118(self) @variable.builtin
154(self) @variable.builtin
119−(metavariable) @variable
120
155
121[
156[
122(char_literal)
157(char_literal)
@@ -133,7 +168,44 @@
133(attribute_item) @attribute
168(attribute_item) @attribute
134(inner_attribute_item) @attribute
169(inner_attribute_item) @attribute
135
170
136−"as" @operator
171+[
137−"*" @operator
172+"*"
173+"'"
174+"->"
175+"=>"
176+"<="
177+"="
178+"=="
179+"!"
180+"!="
181+"%"
182+"%="
138−"&" @operator
183+"&"
184+"&="
185+"&&"
186+"|"
187+"|="
188+"||"
189+"^"
190+"^="
191+"*"
192+"*="
193+"-"
194+"-="
195+"+"
196+"+="
197+"/"
198+"/="
199+">"
200+"<"
201+">="
202+">>"
203+"<<"
204+">>="
205+"@"
206+".."
207+"..="
208+"'"
139−"'" @operator
209+] @operator
210+
211+"?" @special
theme.toml+2−1
@@ -1,9 +1,11 @@
1"attribute" = "#dbbfef" # lilac
1"attribute" = "#dbbfef" # lilac
2"keyword" = "#eccdba" # almond
2"keyword" = "#eccdba" # almond
3"keyword.directive" = "#dbbfef" # lilac -- preprocessor comments (#if in C)
3"keyword.directive" = "#dbbfef" # lilac -- preprocessor comments (#if in C)
4+"namespace" = "#dbbfef" # lilac
4"punctuation" = "#a4a0e8" # lavender
5"punctuation" = "#a4a0e8" # lavender
5"punctuation.delimiter" = "#a4a0e8" # lavender
6"punctuation.delimiter" = "#a4a0e8" # lavender
6"operator" = "#dbbfef" # lilac
7"operator" = "#dbbfef" # lilac
8+"special" = "#efba5d" # honey
7# "property" = "#a4a0e8" # lavender
9# "property" = "#a4a0e8" # lavender
8"property" = "#ffffff" # white
10"property" = "#ffffff" # white
9"variable" = "#a4a0e8" # lavender
11"variable" = "#a4a0e8" # lavender
@@ -31,7 +33,6 @@
31# TODO: variable as lilac
33# TODO: variable as lilac
32# TODO: mod/use statements as white
34# TODO: mod/use statements as white
33# TODO: mod stuff as chamois
35# TODO: mod stuff as chamois
34−# TODO: add "(scoped_identifier) @path" for std::mem::
35#
36#
36# concat (ERROR) @syntax-error and "MISSING ;" selectors for errors
37# concat (ERROR) @syntax-error and "MISSING ;" selectors for errors
37
38