fix(highlighting): Improve highlighting for Magik language#63155
fix(highlighting): Improve highlighting for Magik language#63155
Conversation
sebastiaanspeck
left a comment
There was a problem hiding this comment.
_not is missing in the array of keywords
docker-images/syntax-highlighter/crates/syntax-analysis/queries/magik/highlights.scm
Outdated
Show resolved
Hide resolved
|
@sebastiaanspeck This |
|
As a general comment; we did not use the |
docker-images/syntax-highlighter/crates/syntax-analysis/queries/magik/highlights.scm
Show resolved
Hide resolved
| (character_literal) | ||
| ] @constant | ||
|
|
||
| [ |
There was a problem hiding this comment.
To prepare for the upgrade to the latest tree-sitter, I would suggest to move this array to the top of the file. Since tree-sitter 21.0 they removed the apply-all-captures flag, making last-wins precedence the default.
NOTE: This change might cause breakage in your grammar's highlight tests.
Just flip the order around of the relevant queries, and keep in mind that the
last query that matches will win.
Keeping the current order results into a test failure:
_package user
# <- keyword
# ^ identifier.module
syntax highlighting:
✗ package.magik
Failure - row: 0, column: 10, expected highlight 'identifier.module', actual highlights: 'variable'
There was a problem hiding this comment.
Thanks for pointing that out, I think we will need to do work across all our highlighting files when we upgrade to this version since I believe many will have issues. I will plan to wait for that change and test them all together
There was a problem hiding this comment.
Is there any roadmap for upgrading the tree-sitter? I also wonder if it would be useful to use highlight.scm (and locals.scm etc.) from the original repository. It creates a lot of overhead for this repository and extra work to keep this repository up-to-date if the grammar ever changes
There was a problem hiding this comment.
Is there any roadmap for upgrading the tree-sitter?
Not at the moment.
I also wonder if it would be useful to use highlight.scm (and locals.scm etc.) from the original repository. It creates a lot of overhead for this repository and extra work to keep this repository up-to-date if the grammar ever changes
From Sourcegraph's POV, upstream highlighting queries (in general, not specific to Magik) are neither sufficiently standardized nor always correct (because maybe the maintainer isn't using them, but they were added some some drive-by contributor), so it's best for us to have all the highlighting queries so we can evolve them together.
There was a problem hiding this comment.
Clear story, I am planning myself to back-port the highlights.scm after this PR is merged to make it easier for other projects to adopt the original repository instead of writing it again on their own and to make the original repository more complete, with tests
There was a problem hiding this comment.
That's fair. However, not all grammar maintainers are equally responsive (for understandable reasons), and we need a strategy that works generally.
There was a problem hiding this comment.
That's fair. However, not all grammar maintainers are equally responsive (for understandable reasons), and we need a strategy that works generally.
We are grateful to make our grammar (and highlights) even better thanks to you. Right now, we are our only users and it is a good test to see if we missed anything by having a third party integrate our grammar. Hopefully the fork you created of our grammar is soon superfluous.
Update Magik highlighting to better classify
_unsetand symbols.Test plan
Changelog