@@ -1,52 +1,52 @@
1−pub struct LanguageMode {
2− parser: Parser,
3−}
4−
5−impl LanguageMode {
6− // buffer, grammar, config, grammars, sync_timeout?
7− pub fn new() -> Self {
8− unimplemented!()
9− // make a new root layer
10− // track markers of injections
11− //
12− // track scope_descriptor: a Vec of scopes for item in tree
13− //
14− // fetch grammar for parser based on language string
15− // update root layer
16− }
1+// pub struct Syntax {
2+// parser: Parser,
3+// }
174
18− // fn buffer_changed -> call layer.update(range, new_text) on root layer and then all marker layers
19−
20− // call this on transaction.apply() -> buffer_changed(changes)
21− //
22− // fn parse(language, old_tree, ranges)
23− //
24− // fn tree() -> Tree
25− //
26− // <!--update_for_injection(grammar)-->
27−
28− // Highlighting
29− // fn highlight_iter() -> iterates over all the scopes
30− // on_tokenize
31− // on_change_highlighting
32−
33− // Commenting
34− // comment_strings_for_pos
35− // is_commented
36−
37− // Indentation
38− // suggested_indent_for_line_at_buffer_row
39− // suggested_indent_for_buffer_row
40− // indent_level_for_line
41−
42− // TODO: Folding
43−
44− // Syntax APIs
45− // get_syntax_node_containing_range ->
46− // ...
47− // get_syntax_node_at_pos
48− // buffer_range_for_scope_at_pos
49−}
5+//impl Syntax {
6+// // buffer, grammar, config, grammars, sync_timeout?
7+// pub fn new() -> Self {
8+// unimplemented!()
9+// // make a new root layer
10+// // track markers of injections
11+// //
12+// // track scope_descriptor: a Vec of scopes for item in tree
13+// //
14+// // fetch grammar for parser based on language string
15+// // update root layer
16+// }
17+
18+// // fn buffer_changed -> call layer.update(range, new_text) on root layer and then all marker layers
19+
20+// // call this on transaction.apply() -> buffer_changed(changes)
21+// //
22+// // fn parse(language, old_tree, ranges)
23+// //
24+// // fn tree() -> Tree
25+// //
26+// // <!--update_for_injection(grammar)-->
27+
28+// // Highlighting
29+// // fn highlight_iter() -> iterates over all the scopes
30+// // on_tokenize
31+// // on_change_highlighting
32+
33+// // Commenting
34+// // comment_strings_for_pos
35+// // is_commented
36+
37+// // Indentation
38+// // suggested_indent_for_line_at_buffer_row
39+// // suggested_indent_for_buffer_row
40+// // indent_level_for_line
41+
42+// // TODO: Folding
43+
44+// // Syntax APIs
45+// // get_syntax_node_containing_range ->
46+// // ...
47+// // get_syntax_node_at_pos
48+// // buffer_range_for_scope_at_pos
49+//}
5050
5151pub struct LanguageLayer {
5252 // mode
@@ -55,12 +55,12 @@ pub struct LanguageLayer {
5555// tree: Tree,
5656}
5757
58−impl LanguageLayer {
59− // fn highlight_iter() -> same as Mode but for this layer. Mode composits these
60− // fn buffer_changed
61− // fn update(range)
62− // fn update_injections()
63−}
58+// impl LanguageLayer {
59+// // fn highlight_iter() -> same as Mode but for this layer. Mode composits these
60+// // fn buffer_changed
61+// // fn update(range)
62+// // fn update_injections()
63+// }
6464
6565// -- refactored from tree-sitter-highlight to be able to retain state
6666// TODO: add seek() to iter
@@ -189,13 +189,19 @@ struct HighlightIterLayer<'a> {
189189 depth: usize,
190190}
191191
192−impl Highlighter {
193− pub fn new() -> Self {
192+impl Default for Highlighter {
193+ fn default() -> Self {
194194 Highlighter {
195195 parser: Parser::new(),
196196 cursors: Vec::new(),
197197 }
198198 }
199+}
200+
201+impl Highlighter {
202+ pub fn new() -> Self {
203+ Self::default()
204+ }
199205
200206 pub fn parser(&mut self) -> &mut Parser {
201207 &mut self.parser