Module difft::parse::tree_sitter_parser
source · [−]Expand description
Load and configure parsers written with tree-sitter.
Structs
Configuration for a tree-sitter parser.
A language may contain certain nodes that are in other languages
and should be parsed as such (e.g. HTML
<script>
nodes containing
JavaScript). This contains how to identify such nodes, and what
languages we should parse them as.Constants
Functions
Convert all the tree-sitter nodes at this level to difftastic
syntax nodes.
Convert the tree-sitter node at
cursor
to a difftastic atom.Are any of the children of the node at
cursor
delimiters? Return
their indexes if so.Convert the tree-sitter node at
cursor
to a difftastic list
node.parse 🔒
Parse
src
with tree-sitter and convert to difftastic Syntax.Find any nodes that can be parsed as other languages (e.g. JavaScript embedded in HTML),
and return a map of their node IDs mapped to parsed trees. Every time we see such a node,
we will ignore it and recurse into the root node of the given tree instead.
Convert the tree-sitter node at
cursor
to a difftastic syntax
node.to_tree 🔒
Parse
src
with tree-sitter.Calculate which tree-sitter node IDs should have which syntax
highlighting.