Syntax highlighting for nested Lezer grammars?


I’m really enjoying using Lezer so far! The build errors have been immensely helpful and I’ve found it a lot easier to debug than other parser generators so first off, thank you a ton for the great work :slight_smile:

I’m having trouble getting my nested Lezer grammar to work well with syntax highlighting, specifically I’m nesting Markdown within a language I’m creating. I’m adding in both sets of tokens in the same parser.configure call but only the tokens for the outermost language (my new one) seem to be getting tagged. I’ve also added the markdown().support extension, but that didn’t make a difference either.

Are there any examples of CM6 with syntax highlighting across nested grammars I can reference?

Yes, the highlighting metadata is being added directly to the node type objects (which are owned by the parser), so you need to configure the inner parser before you pass it to the outer parser to get your highlighting configuration for that one to show up in the document.