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

Macro highlighting failing after update #134

Closed
lmburns opened this issue Mar 12, 2022 · 3 comments
Closed

Macro highlighting failing after update #134

lmburns opened this issue Mar 12, 2022 · 3 comments

Comments

@lmburns
Copy link

lmburns commented Mar 12, 2022

I'm unsure when this happened in the commits, I have treesitter update everyday, so I believe it has been since last night. I'm also unsure if this has to do with this repo or the main treesitter repo. However, attribute-macros no longer highlight with my code. #[derive(...)] does, but #[serde(...)] does not.

The highlight group under #[derive(...)] is the following:

# Treesitter
* **@variable** -> **rustTSVariable** -> **TSVariable**
* **@function.macro** -> **rustTSFuncMacro** -> **TSFuncMacro**
* **@_name** -> **rust0** -> **0**
* **@_name** -> **rust0** -> **0**
* **@_name** -> **rust0** -> **0**
* **@_name** -> **rust0** -> **0**
* **@_name** -> **rust0** -> **0**

The highlight group under #[serde(...)] is the following:

# Treesitter
* **@variable** -> **rustTSVariable** -> **TSVariable**

Picture to show an example:
Alacritty_2022-03-11_19-54

@ninevra
Copy link
Contributor

ninevra commented Mar 12, 2022

@aryx This looks to me like the intended effect of #93? #[serde()] is not a built-in macro, so #93 causes tree-sitter to parse it as an attr_item rather than a meta_item, which, being a new node type, is presumably not highlighted (I'm not at all familiar with how syntax highlighting with tree-sitter works, sorry).

Avoiding this kind of breaking change while supporting non-meta-item attributes would probably require a different approach than #93, probably using injections as @resolritter suggested in #93 (comment).

@aryx
Copy link
Contributor

aryx commented Mar 12, 2022

It's not highlighted because highlights.scm needs to be updated to take into account the new attr_item construct?

@ninevra
Copy link
Contributor

ninevra commented Mar 17, 2022

Maybe? I don't see anything in highlights.scm (nor in the other queries) that looks like it handles the internal structure of attributes at all. There's just:

(attribute_item) @attribute
(inner_attribute_item) @attribute

Are there any tests for syntax highlighting, or an example of how best to write such tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants