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

Syntax highlighting for macros #10281

Open
Milo123459 opened this issue Sep 19, 2021 · 6 comments
Open

Syntax highlighting for macros #10281

Milo123459 opened this issue Sep 19, 2021 · 6 comments
Labels
A-highlighting (semantic) token highlighting A-macro macro expansion C-feature Category: feature request E-hard fun A technically challenging issue with high impact S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@Milo123459
Copy link
Contributor

Milo123459 commented Sep 19, 2021

Very far-fetch with little logic behind it

Syntax highlighting inside of macros. Something parses the content inside a macro, and theoretically speaking this could be used for syntax highlighting inside of a macro.

For example, take the xflags macro. This crate has its own syntactical sugar inside of the macro, and syntax highlighting for it would be cool. Theoretically, it just has to parse how the macro is defined and send that back to the editor, but it is probably more complex than that.

Not sure how this would work with proc-macros.

@flodiebold
Copy link
Member

flodiebold commented Sep 19, 2021

Kind of related to #7402; for something like xflags the proc macro would need to provide us with information about the meaning of tokens that are in the macro input but not the output. (Tokens that are passed through to the output should be highlighted according to their meaning there.) Would be pretty cool, but it's a bit far off, I think.

(On the other hand, this is something that would take time to permeate through the ecosystem, so it'd benefit from being started early. So if someone really cares about this and would be willing to put in the work, this might be an interesting project.)

@flodiebold flodiebold added A-macro macro expansion E-hard S-unactionable Issue requires feedback, design decisions or is blocked on other work C-feature Category: feature request fun A technically challenging issue with high impact labels Sep 19, 2021
@Milo123459
Copy link
Contributor Author

E-hard sums it up. Although, this is a feature that would probably be one of the most valued things to me personally

@Veykril Veykril added the A-highlighting (semantic) token highlighting label Dec 4, 2021
@Milo123459 Milo123459 changed the title FR: Syntax highlighting for macros mSyntax highlighting for macros Jul 15, 2022
@Milo123459 Milo123459 changed the title mSyntax highlighting for macros myntax highlighting for macros Jul 15, 2022
@Milo123459 Milo123459 changed the title myntax highlighting for macros Syntax highlighting for macros Jul 15, 2022
@Milo123459
Copy link
Contributor Author

I would like to start working on this. Any ideas of how I should start?

@Veykril
Copy link
Member

Veykril commented Feb 9, 2023

A rough idea would be to leverage #11556 and have proc-macros re-use input tokens that are usually discarded in such helpers attributes so r-a can make use of them for highlighting.

@Milo123459
Copy link
Contributor Author

Is it possible to make it fully automatic, and require the project to not need to manually annotate anything? That issue makes it seem manual.

@Veykril
Copy link
Member

Veykril commented Feb 9, 2023

There is no way for us to make this automatic for tokens that are not used by the macro. If the macro doesn't use the tokens there is nothing r-a can know about them. Parsing the proc-macro definition is not an option, as that is just rust code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-highlighting (semantic) token highlighting A-macro macro expansion C-feature Category: feature request E-hard fun A technically challenging issue with high impact S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

3 participants