Skip to content
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

Fix Broken Attribute Highlights #5349

Merged

Conversation

Chickenkeeper
Copy link
Contributor

The deleted code contained keys that aren't used by Helix's themes, caused inconsistent highlighting of punctuation, highlighted lowercase arguments as integers, and was in the wrong section of the file.

However it was also highlighting derive as @special instead of function.macro, so if we want to keep that behaviour then maybe something like this could be inserted at the top of the Macros section instead?

(attribute
  (identifier) @special
  (#eq? @special "derive")
)

@the-mikedavis
Copy link
Member

@special is undocument but used in a bunch of themes. It's used for rust's ? operator and in the picker for highlighted matches. @_macro or any other scope with an underscore is used within a match just so the capture can be referenced in the predicate: here it's used so we can assert that the attribute's name is derive. The @_macro capture can probably be replaced with @special so that the @special highlighting doesn't apply to the #[/,/] parts of the attribute. The only thing that looks really out-of-place to me in this stanza is the constant.numeric.integer capture. I didn't test this but it can most likely be removed or replaced with @type

@kirawi kirawi added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. A-language-support Area: Support for programming/text languages labels Jan 1, 2023
@Chickenkeeper
Copy link
Contributor Author

That makes sense. I've added the stanza I suggested plus your suggestion of capturing the arguments as type instead of constant.numeric.integer to handle the edge case where a derive might need to use a trait with a lowercase name, or to stop the colour changing as a name is being typed. I've also added special to the docs, as well as type.enum.variant which is also used a lot but undocumented

@Chickenkeeper Chickenkeeper changed the title Remove Broken Attribute Highlights Fix Broken Attribute Highlights Jan 3, 2023
@the-mikedavis the-mikedavis added S-waiting-on-review Status: Awaiting review from a maintainer. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 3, 2023
@archseer archseer merged commit 486c3ab into helix-editor:master Jan 9, 2023
kirawi pushed a commit to kirawi/helix that referenced this pull request Jan 25, 2023
* Update highlights.scm

* Update highlights.scm

* Update themes.md
@Chickenkeeper Chickenkeeper deleted the rust-attribute-highlight-fix branch February 8, 2023 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants