For anyone that finds this thread, there’s now a TreeSitter
package for Sublime Text: https://github.com/sublime-treesitter/TreeSitter.
It provides Sublime Text with a performant and flexible interface to Tree-sitter. It works out of the box with around 40 languages, and can be configured to work with any language that has a Tree-sitter grammar.
Tree-sitter builds a parse tree for text in any buffer, fast enough to update the tree after every keystroke. Sublime already has a great syntax highlighting system, but Tree-sitter parse trees can be used for a bunch of other things as well.
The package ships with commands for “tree-based” selection and navigation. For example, you can select ancestor, descendant, or “cousin” nodes based on the current selection. This e.g. makes it easy to select the whole class or function if your cursor is currently “within” that class or function. You can also go to symbols returned by configurable tree queries, with symbol breadcrumbs for context.
And it exports APIs that let package developers build Tree-sitter based packages and custom commands.