-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Update tree-sitter-sql and improve highlight queries #5683
Update tree-sitter-sql and improve highlight queries #5683
Conversation
Does this also fix #5071? I would guess so since it was solved just by updating the SQL parser when that issue was first opened |
I tested the SQL dump linked at #5071 (https://gist.github.com/tkellogg/bbf57f5c43489a1e122b4f1a8d0daa9b), which
The reporter of #5071 was on MacOS, while I am using Linux, with currently no access to a MacOS device to test on. Since you were able to reproduce the issue on Linux on 9 December, I believe we can assume the crash issue might be fixed. Note that typing is still unbearably slow in this 13 MB file. (No matter if inserting at the top or bottom of the file.) |
Thanks for testing that! I think we can close that issue then once this PR is merged. The performance can likely only be improved by speeding up the grammar although around those file-sizes TS sadly starts to hit its limit. We have enough open issues about that already and the specific crash seems to be solved |
I added "Fixes #5071" to the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to also add the new bang
rule as an operator DerekStride/tree-sitter-sql@2743c7b5e710e6854d4e8c14c302548b436e2a1f...4fe05b2d81565ddb689d2f415e07afdacc515c52
#diff-919ac210ac
What do you mean? The PR already updates to the latest commit. Edit: Might be that GitHub doesn't show me what you are seeing, as I checked your link on mobile. |
Oh yeah that diff is not expanding properly. I meant this line https://github.com/DerekStride/tree-sitter-sql/blob/4fe05b2d81565ddb689d2f415e07afdacc515c52/grammar.js#L1438 It could be added to the big (binary_expression
operator: _ @operator)
(unary_expression
operator: _ @operator) |
I mean that you could replace the block here: helix/runtime/queries/sql/highlights.scm Lines 45 to 59 in 4a59d33
with: (binary_expression
operator: _ @operator)
(unary_expression
operator: _ @operator) as-is: Fields make it easy to capture some specific node in a pattern and can capture arbitrary things. For example you could use the
So they're nice for a case like this where we want to tag everything that could show up in that |
Thanks! Makes perfect sense to me. The difference here is that
Should I add the following?
Not sure if As a user, I would actually like After working quite expansively with SQL in hx in the recent weeks, I believe a lot more different colors should be used for various SQL node types. Maybe this shouldn't be solved at the level of individual themes, but rather by applying more fine-grained node names, so not (almost) everything is a Edit: This also appears to be the theme's problem - other themes apply far more colors, e.g. to table and field names: Where can I see which node types helix uses to apply highlight? For Example:
|
When I was updating the queries I chose the semantically appropriate scopes. You can see it here: helix/runtime/queries/sql/highlights.scm Lines 10 to 29 in 4a59d33
I didn't know that some themes haven't |
Also what about #5708, I'm not sure how helix loads tree-sitter grammars (line by line or in some other way), but I just swapped these lines and it seems the numbers are highlighted correctly now |
Yeah, the original SQL queries were most likely written for nvim-treesitter which has the reverse precedence: in nvim-treesitter, later queries override earlier ones and in helix earlier queries override later queries. So swapping those two clauses should fix those highlights. |
That |
You can check the |
I added that to the PR in 332ad7f
Thank you, that was SO helpful! Together with the scopes at https://docs.helix-editor.com/themes.html#scopes and
I flipped the two directives in 7e41845 Also added "Fixes #5708" to PR description. Edit: Force-pushed to force GitHub to update the PR after it failed to import the last commit added to the branch. Also did a master rebase in the process. (22b3d3d..2c6bf6f) |
7e41845
to
4ed120a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for working on this!
Fixes #5186
Fixes #5071
Fixes #5708
See also:
highlights.scm
SQL highlighting issue in helix-editor, using tree-sitter-sql DerekStride/tree-sitter-sql#67 (comment)