Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

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 :

code start

Installation

Installation took two steps

- Clone the repo for the desired language

- Update [TODO: Code shorthand span ] array in the config.json file to add the parent directory above the repo

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

cd ~/workshop
git clone git@github.com:tree-sitter/tree-sitter-html.git
json
{
  "parser-directories": [
    "/Users/alan/workshop"
  ],

  "other_config_stuff": {}
}

Running The Example

With that in place, this works and highlights the HTML properly

tree-sitter highlight example.neo

Footnotes And References

  • neo
    Neopolitan

    My mardkdown - like plain - text file format

  • ts
    Tree-sitter

    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

  • tree-sitter-html

    The HTML language parser/highlighter repo for Tree - sitter