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 :
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
Running The Example
With that in place, this works and highlights the HTML properly
tree-sitter highlight example.neo
Footnotes And References
- Neopolitan
My mardkdown - like plain - text file format
- 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