genotrance / nimtreesitter

treesitter is a Nim wrapper for the tree-sitter library
MIT License
25 stars 4 forks source link

treesitter is a Nim wrapper for the tree-sitter library.

treesitter is distributed as a Nimble package and depends on nimgen and c2nim to generate the wrappers. The tree-sitter source code is downloaded using Git so having git in the path is required.

Installation

treesitter can be installed via Nimble:

> nimble install treesitter

This will download, wrap and install treesitter in the standard Nimble package location, typically ~/.nimble. Once installed, it can be imported into any Nim program.

Individual language grammars can be installed as well to parse source files:

> nimble install treesitter_c

This will download, wrap and install the C grammar. Given treesitter is a dependency, any language grammar can be installed directly and treesitter will get installed automatically.

Grammars are available for the following languages:

Usage

Refer to the tests directory for examples on how the library can be used.

Credits

This library wraps the tree-sitter source code and all licensing terms of tree-sitter apply to the usage of this package.

Credits go out to c2nim as well without which this package would be greatly limited in its abilities.

Feedback

treesitter is a work in progress and any feedback or suggestions are welcome. It is hosted on GitHub with an MIT license so issues, forks and PRs are most appreciated.