Switching between two grammars in a package

#1

I have a grammar package that where I’m developing a tree-sitter parser. But while that second grammar is in development I’d like people to have the option to pick which grammar gets used. I already figured out how to do the config:

module.exports = {
  config: {
    enableTreeSitter: {
      title: "Enable Tree Sitter",
      description: "Use experimental parser",
      type: "boolean",
      default: false
    }
  }
}

atom.config.observe("mcfunction-plus.enableTreeSitter", (enabled) => { ... }

I have found a few quirks to get the grammars.

atom.grammars.getGrammars().filter(g => g.scopeName === "source.mcfunction")

This only returns the TextMate grammar.

atom.grammars.grammarForScopeName("source.mcfunction");

And this gives the Tree Sitter grammar, probably because it has priority and is enabled by default?

So anyways that’s where I’m at. I’d like to now switch which grammar is used.