Is it possible/easy to build a VS Code extension that does syntax highlighting with a lexer?


I am building an experimental lexer generator and I think it would be cool to output simple syntax highlighters for VS Code. The input grammar goes through the classic regular language -> NFA -> DFA transformation, then generates state machine code (it also has some unconventional features to support nested languages). Converting all this back into tmlanguage definitions is a complicated problem, and I’m starting to wonder if a VS Code extension is a better option. The question is:

  • Are VS Code syntax highlighting internals completely tied to the tmlanguage regex scanner, or would it be possible to write an extension that provides tokens / highlight ranges programmatically?
  • Is there an API that would make this reasonably straightforward, or would this project be a tour de force?


As of VSCode 1.15, you have to use textmate grammars for syntax highlighting. There’s an feature request open that tracks what you are after:

Answered By – Matt Bierner

Answer Checked By – Mary Flores (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.