Skip to content

Conversation

@StratusFearMe21
Copy link
Contributor

@StratusFearMe21 StratusFearMe21 commented Aug 28, 2025

Hi!

I'd love to be able to use tree-house as a highlighter for a custom presentation language I'm working on, but I'm not able to without the ability to load tree-sitter grammars from Rust crates. This PR gives tree-house-bindings the ability to do that.

@the-mikedavis
Copy link
Member

I was wondering what it would take to load grammars like the upstream bindings with tree-sitter-language. In Helix we stick to loading shared objects but I know that many tree-sitter apps use the crates and similar higher-level bindings. This is pretty slim, nice!

How does this look in your use-case? There aren't really any docs to speak of for tree-house yet but this is definitely something I want to document in the long-run so I'm curious how you would use these changes.

@StratusFearMe21
Copy link
Contributor Author

This would be the syntax for loading a grammar

use tree_house_bindings::{Parser, Grammar};

let mut parser = Parser::new();
parser
    .set_grammar(Grammar::try_from(tree_sitter_grz::LANGUAGE).unwrap())
    .unwrap();

From there it would just work like normal

@StratusFearMe21
Copy link
Contributor Author

StratusFearMe21 commented Aug 28, 2025

My main use-case for tree-house right now is for syntax highlighting errors within my presentation language here and using the API via my language's language server which links to helix-lsp and helix-lsp-types which provides a conveniant API for converting language server edits to transactions which can be applied to a Rope.

And since I use the original tree-sitter crate for the actual parsing of the language, I would ideally replace that with tree-house-bindings to not have to have two tree-sitter bindings within the same project

@the-mikedavis the-mikedavis merged commit e8b04f3 into helix-editor:master Aug 31, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants