71 / vscode-tree-sitter-api

Exposing Tree Sitter parsers and queries to VS Code extensions (with caching & more utilities).
Mozilla Public License 2.0
14 stars 2 forks source link

Package status? #1

Open haberdashPI opened 2 months ago

haberdashPI commented 2 months ago

Hi there, I'm interested in incorporating tree-sitter queries into my keybindings, and have been thinking about how to do this.

I'm wondering what the status of this package is, and what your experience has been like, attempting to make use of tree-sitter queries in VSCode.

  1. Has this approach worked out well for your own personal use?
  2. Have there been any particular roadblocks?
  3. Have you thought at all about how to deal with the fact that each language needs its own set of compiled binaries (is there a good way to organize only downloading the language specs required by the user, or does any extension that binds to tree sitter APIs need to bind to all languages it plans to support).

Just curious about any insight you've gained in trying to do this.

71 commented 2 months ago

Hey there!

  1. I primarily use this extension through Dance, but I admittedly don't use Tree Sitter-based queries much. With that said, selecting the current function/type seems to work well in supported languages, and the lazy approach taken by this extension should make it fairly lightweight when not used.
  2. Not really; I feel like all the core features and workflow is there. Adding support for new languages isn't trivial, but is fairly easy (modifying these lines in the extension and updating the dependencies), with tools.ts taking care of a lot of the work (like importing text objects from Helix). The feature set seems satisfying to me. I know there is a "WIP" label in the README, but it's mostly there because I want to be open to changes and feedback in case the API / developer experience could be significantly improved.
  3. Yep... Right now, all languages are compiled as separate .wasm files which are loaded lazily when a query is issued in a document of a particular language. With 10 languages, the .vsix weighs ~700KB, with individual .wasm files weighing from 30KB to 1.6MB (so .wasm files compress pretty well). If support for even more languages were to be added (let's say 20 languages, which could bring the extension >1MB), one option would be to release separate extensions on the marketplace, each of which depends on a "core" Tree Sitter extension. I feel like the user experience wouldn't be great, though (notably if breaking changes are introduced), so maybe instead they could be downloaded by the extension automatically, but that feels iffy from a security perspective (although many extensions behave this way).
haberdashPI commented 2 months ago

Thanks for the thoughtful answers @71! I might try this out with my own keybinding setup.