Platform:

Creating a grammar

Pulsar’s syntax highlighting and code folding are powered by packages called grammars. A grammar is something that knows how to analyze a certain language in order to provide syntax highlighting, code folding, and indentation hinting.

Pulsar grammars come in a few flavors:

Tree-sitter grammars are relatively new. Many languages in Pulsar are still supported by TextMate grammars and TextMate grammars are easier to write from scratch, so they may still be the best option for more obscure languages. Tree-sitter grammars assume the existence of a Tree-sitter parser having been written for a particular language. But if such a parser exists, a Tree-sitter grammar will be more performant and easier to author.

The package

A “grammar package” is just an ordinary Pulsar package that happens to contain one or more grammars. It can do anything that any other Pulsar package can do — run code, declare keybindings and styles, and so on — but usually doesn’t need to.

When Pulsar loads a package during startup, it will check for the existence of a grammar directory at the package root. This is where your grammars should be placed, with the format differing based on the type of grammar.