-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically install tree-sitter queries (if they exist) on grammar build #3019
Comments
I don't think that's a good idea since this only makes sense when you're building from source (where it's OK to have some extra steps -- you have to set up your runtime path. I actually recommend setting the env variable instead of copying or symlinking to the user config dir). Distributions package using the exact same commands except the runtime is stored in /usr/lib or similar. |
@archseer Does this mean that if I was running a distribution build, and I had, in my ~/.config/helix/languages.toml:
And I ran: hx --grammar fetch my_lang
hx --grammar build my_lang The queries in the grammar from the git repository would automatically be used by Helix? Without having to manually create them in runtime/queries? I guess I’m confused about why it would behave differently between when installed from a distribution and when built from source but I know very little of the inner workings of Helix Editor so it could be that I’m missing something fundamental here :) |
No, we don't use the queries from the grammar repos. #3020 (comment) is one reason but also:
It's also unreasonable on the grammar author for us to expect that any tree-sitter grammar we use has helix-specific queries, plus it would be a pain to update decentralized queries. The current state of the art is for grammar repositories to create queries that work with
It depends on the distribution but typically they assemble a runtime directory in some In order to support syntax highlighting, we need the language and grammar configurations in |
All of that being said, it would be an improvement to bundle queries and grammars because queries depend on the version of the parser: query analysis will fail when old queries are used with a new parser that makes a breaking change like renaming or removing named nodes. I'll make a follow-up issue. |
Use case
I create, fetch, and build a new tree-sitter grammar. I launch Helix Editor to see my new tree sitter grammar in action.
What should happen
I should see it working.
What actually happens
Nothing.
How I troubleshoot
I enter
hx --health my_lang
and I see that highlighting and indentation are not being applied for it.I look inside my tree-sitter grammar folder and I see that
injections.scm
, etc., exist in itsqueries
folder.I see that the grammar, including the queries folder has been correctly checked out and is in runtime/grammars.
I’m confused.
I check out the documentation on adding languages and notice the note about how queries have to be added manually to runtime/queries.
I’m left wondering why running
hx --grammar build my_lang
didn’t just copy my queries folder from my tree-sitter grammar to runtime/queries for me.Suggested implementation
Running
hx --grammar build my_lang
should copy the queries directory from the tree-sitter grammar (if one exists) to runtime/queries as part of the build/installation process.The text was updated successfully, but these errors were encountered: