on master help sign in
Adjust highlighting for rust.
commit6e03019a2c7ec6e9d00a6308fe716468f767dd58 authorBlaž Hrastnik <blaz@mxxn.io> dateSun 16 May 2021, 18:58 (5 years ago) parent31d4108
3 files changed+84−16
TODO.md−5 runtime/queries/rust/highlights.scm+82−10 theme.toml+2−1
TODO.md−5
@@ -1,5 +1,4 @@
11- Refactor tree-sitter-highlight to work like the atom one, recomputing partial tree updates.
2−- syntax errors highlight query
32
43------
54
@@ -19,15 +18,11 @@
1918- [ ] document.on_type provider triggers
2019- [ ] completion isIncomplete support
2120
22−- [ ] extract indentation calculation queries so we can support other languages.
23−
24211
25−- [ ] :format/:fmt that formats the buffer
2622- [ ] respect view fullscreen flag
2723- [ ] Implement marks (superset of Selection/Range)
2824
2925- [ ] nixos packaging
30−- [ ] CI binary builds
3126
3227- [ ] = for auto indent line/selection
3328- [ ] :x for closing buffers
runtime/queries/rust/highlights.scm+82−10
@@ -1,10 +1,28 @@
11; Identifier conventions
22
3+
34; Assume all-caps names are constants
45((identifier) @constant
56 (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
67
8+; Assume other uppercase names are enum constructors
9+((identifier) @constructor
10+ (#match? @constructor "^[A-Z]"))
11+
712; 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+
826((scoped_identifier
927 path: (identifier) @type)
1028 (#match? @type "^[A-Z]"))
@@ -13,9 +31,15 @@
1331 name: (identifier) @type))
1432 (#match? @type "^[A-Z]"))
1533
16−; Assume other uppercase names are enum constructors
17−((identifier) @constructor
18− (#match? @constructor "^[A-Z]"))
34+; Namespaces
35+
36+(crate) @namespace
37+(scoped_use_list
38+ path: (identifier) @namespace)
39+(scoped_use_list
40+ path: (scoped_identifier
41+ (identifier) @namespace))
42+(use_list (scoped_identifier (identifier) @namespace . (_)))
1943
2044; Function calls
2145
@@ -38,9 +62,19 @@
3862 function: (field_expression
3963 field: (field_identifier) @function.method))
4064
65+; (macro_invocation
66+; macro: (identifier) @function.macro
67+; "!" @function.macro)
68+(macro_invocation
69+ macro: (identifier) @function.macro)
4170(macro_invocation
42− macro: (identifier) @function.macro
43− "!" @function.macro)
71+ macro: (scoped_identifier
72+ (identifier) @function.macro .))
73+
74+; (metavariable) @variable
75+(metavariable) @function.macro
76+
77+"$" @function.macro
4478
4579; Function definitions
4680
@@ -73,6 +107,7 @@
73107";" @punctuation.delimiter
74108
75109(parameter (identifier) @variable.parameter)
110+(closure_parameters (_) @variable.parameter)
76111
77112(lifetime (identifier) @label)
78113
@@ -114,9 +149,9 @@
114149(scoped_use_list (self) @keyword)
115150(scoped_identifier (self) @keyword)
116151(super) @keyword
152+"as" @keyword
117153
118154(self) @variable.builtin
119−(metavariable) @variable
120155
121156[
122157(char_literal)
@@ -133,7 +168,44 @@
133168(attribute_item) @attribute
134169(inner_attribute_item) @attribute
135170
136−"as" @operator
137−"*" @operator
138−"&" @operator
139−"'" @operator
171+[
172+"*"
173+"'"
174+"->"
175+"=>"
176+"<="
177+"="
178+"=="
179+"!"
180+"!="
181+"%"
182+"%="
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+"'"
209+] @operator
210+
211+"?" @special
theme.toml+2−1
@@ -1,9 +1,11 @@
11"attribute" = "#dbbfef" # lilac
22"keyword" = "#eccdba" # almond
33"keyword.directive" = "#dbbfef" # lilac -- preprocessor comments (#if in C)
4+"namespace" = "#dbbfef" # lilac
45"punctuation" = "#a4a0e8" # lavender
56"punctuation.delimiter" = "#a4a0e8" # lavender
67"operator" = "#dbbfef" # lilac
8+"special" = "#efba5d" # honey
79# "property" = "#a4a0e8" # lavender
810"property" = "#ffffff" # white
911"variable" = "#a4a0e8" # lavender
@@ -31,7 +33,6 @@
3133# TODO: variable as lilac
3234# TODO: mod/use statements as white
3335# TODO: mod stuff as chamois
34−# TODO: add "(scoped_identifier) @path" for std::mem::
3536#
3637# concat (ERROR) @syntax-error and "MISSING ;" selectors for errors
3738