Grammar in the same repo as language package or a separate repo?


I wanted to what are the advantages and disadvantages of keeping a lezer grammar in the same repository as the language package versus keeping it in a separate repository.

Most CodeMirror official packages seem to have a separate repos for language support and their lezer grammars. However, the example package contains the lezer grammar in the same repo, and a lot of third-party packages also seem to follow this convention.

Having a single repo seems like the easier choice in terms of the build system and versioning, but maybe that makes it harder to use the parser without the rest of codemirror?

So, should the .grammar file be in a codemirror-lang-* repo or a separate lezer-* repo?

A single repository is fine. For parsers that I expect to possibly be used outside of the editor, I’ve been providing separate parser packages, so people can load them without pulling in @codemirror dependencies. But if you are just building an editor support package, there’s no need to bother with that.

1 Like