Lezer parsing as a CM5 mode?

I’m at an awkward, transitional phase migrating to CodeMirror 6.

I need to write a new mode, to support CM5. Is it possible to create a CM5 mode that wraps a lezer grammar?

Not really. The data provided to a a CM5-style mode (one line of the document at a time) is very different to the input to Lezer parsers (entire document, along with information about changes so it can figure out what it may reuse). It might be possible to write an adaptor that runs a Lezer parser on the content of a CM5 editor and somehow kludges a mode to read the information from the resulting tree, but due to the various conceptual mismatches I suspect that would get very clunky.

1 Like

Thanks very much