I’m trying to use codemirror.next for Python. It seems like writing the Python grammar in Lezer is not currently support, so in the meantime I was planning on using tree-sitter-python as a fill-in. I’m implementing a
Syntax service that translates from a tree-sitter Tree into a Lezer Tree. My immediate goal is to get Python syntax highlighting working.
It’s easy enough to derive a
NodeType for each tree-sitter node, but I’m having trouble creating a Lezer
Tree. Right now, I’m fine with something’s that inefficient since my use case is primarily read-only. I was trying to create a
Tree for each node, but that doesn’t work because
Tree only works at the toplevel (
end are fixed to 0 and length). Presumably the inner nodes have to be
But there I’m also in a bind.
NodeSubtree expects a parent
Subtree to its constructor. But the parent
Tree expects. a list of
children to its constructor. So it’s not clear how to satisfy both dependencies.
What is the recommended way to do this?