@@ -1,52 +1,52 @@
1−pub struct LanguageMode {
1+// pub struct Syntax {
2− parser: Parser,
2+// parser: Parser,
6− // buffer, grammar, config, grammars, sync_timeout?
7− pub fn new() -> Self {
9− // make a new root layer
10− // track markers of injections
12− // track scope_descriptor: a Vec of scopes for item in tree
14− // fetch grammar for parser based on language string
6+// // buffer, grammar, config, grammars, sync_timeout?
7+// pub fn new() -> Self {
9+// // make a new root layer
10+// // track markers of injections
12+// // track scope_descriptor: a Vec of scopes for item in tree
14+// // fetch grammar for parser based on language string
15+// // update root layer
18− // fn buffer_changed -> call layer.update(range, new_text) on root layer and then all marker layers
18+// // fn buffer_changed -> call layer.update(range, new_text) on root layer and then all marker layers
20− // call this on transaction.apply() -> buffer_changed(changes)
20+// // call this on transaction.apply() -> buffer_changed(changes)
22− // fn parse(language, old_tree, ranges)
22+// // fn parse(language, old_tree, ranges)
24− // fn tree() -> Tree
24+// // fn tree() -> Tree
26− // <!--update_for_injection(grammar)-->
26+// // <!--update_for_injection(grammar)-->
28− // Highlighting
28+// // Highlighting
29− // fn highlight_iter() -> iterates over all the scopes
29+// // fn highlight_iter() -> iterates over all the scopes
30− // on_tokenize
30+// // on_tokenize
31− // on_change_highlighting
31+// // on_change_highlighting
33− // Commenting
33+// // Commenting
34− // comment_strings_for_pos
34+// // comment_strings_for_pos
35− // is_commented
35+// // is_commented
37− // Indentation
37+// // Indentation
38− // suggested_indent_for_line_at_buffer_row
38+// // suggested_indent_for_line_at_buffer_row
39− // suggested_indent_for_buffer_row
39+// // suggested_indent_for_buffer_row
40− // indent_level_for_line
40+// // indent_level_for_line
42− // TODO: Folding
42+// // TODO: Folding
44− // Syntax APIs
44+// // Syntax APIs
45− // get_syntax_node_containing_range ->
45+// // get_syntax_node_containing_range ->
47− // get_syntax_node_at_pos
47+// // get_syntax_node_at_pos
48− // buffer_range_for_scope_at_pos
48+// // buffer_range_for_scope_at_pos
51pub struct LanguageLayer {
51pub struct LanguageLayer {
@@ -55,12 +55,12 @@ pub struct LanguageLayer {
55// tree: Tree,
55// tree: Tree,
58−impl LanguageLayer {
58+// impl LanguageLayer {
59− // fn highlight_iter() -> same as Mode but for this layer. Mode composits these
59+// // fn highlight_iter() -> same as Mode but for this layer. Mode composits these
60− // fn buffer_changed
60+// // fn buffer_changed
61− // fn update(range)
61+// // fn update(range)
62− // fn update_injections()
62+// // fn update_injections()
65// -- refactored from tree-sitter-highlight to be able to retain state
65// -- refactored from tree-sitter-highlight to be able to retain state
66// TODO: add seek() to iter
66// TODO: add seek() to iter
@@ -189,13 +189,19 @@ struct HighlightIterLayer<'a> {
189 depth: usize,
189 depth: usize,
192−impl Highlighter {
192+impl Default for Highlighter {
193− pub fn new() -> Self {
193+ fn default() -> Self {
194 Highlighter {
194 Highlighter {
195 parser: Parser::new(),
195 parser: Parser::new(),
196 cursors: Vec::new(),
196 cursors: Vec::new(),
202+ pub fn new() -> Self {
200 pub fn parser(&mut self) -> &mut Parser {
206 pub fn parser(&mut self) -> &mut Parser {
201 &mut self.parser
207 &mut self.parser