-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Problem
The Rust bindings generated by default by tree-sitter init include the following lines in lib.rs:
// NOTE: uncomment these to include any queries that this grammar contains:
// pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm");
// pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm");
// pub const LOCALS_QUERY: &str = include_str!("../../queries/locals.scm");
// pub const TAGS_QUERY: &str = include_str!("../../queries/tags.scm");Unfortunately, grammar maintainers often forget to uncomment those lines to expose the queries to Rust crate reusers. Even if they think about doing it when first generating the bindings, they might not think about it when introducing a new type of query, and their edits might get overwritten when they re-generate the bindings.
This has led me to opening quite a few PRs to have Rust crates expose them: yuja/tree-sitter-qmljs#21, elves/tree-sitter-elvish#5, joelspadin/tree-sitter-devicetree#21, slackhq/tree-sitter-hack#75, briot/tree-sitter-ada#16 … but again, even if those get merged and released, they might get overwritten at the next update.
Overall, it is good to avoid relying on workflows where people edit auto-generated files.
Expected behavior
It would be better if the Rust bindings could automatically expose those queries whenever they are available in the parser's repository.