Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Add A Language To The Tree-sitter CLi Tool

I'm working on the Tree-sitter^ts^^ parser and syntax highlighter for Neopolitan^neo^^. One feature of the format is the ability to embed other languages. It took me a while to figure out that in order for the injected langauges to highlight properly I had to install each language for the CLI tool individually.

I did this in my tree-sitter config.json file which is here on my mac:

~/Library/Application Support/tree-sitter/config.json

For example, I installed the HTML language parser/highlighter in my _~/workshop__ directory with:

Code

cd ~/workshop
git clone git@github.com:tree-sitter/tree-sitter-html.git

Then I added this

Code

{
  "parser-directories": [
    "/Users/alan/workshop"
  ],

  "other_config_stuff": {}
}

Code

tree-sitter highlight example.neo

References

  • My mardkdown-like plain-text file format

  • A parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited

  • The HTML language parser/highlighter repo for Tree-sitter