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&COMP: let a proc macro know if it is invoked during completion #9711

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

vlad20012
Copy link
Member

@vlad20012 vlad20012 commented Nov 11, 2022

Now the plugin sets these environment variables when expands a proc macro during completion: RUST_IDE_PROC_MACRO_COMPLETION=1
RUST_IDE_PROC_MACRO_COMPLETION_DUMMY_IDENTIFIER=IntellijIdeaRulezzz

changelog: Experimentally set RUST_IDE_PROC_MACRO_COMPLETION and RUST_IDE_PROC_MACRO_COMPLETION_DUMMY_IDENTIFIER environment variables for procedural macro when invoking them during completion. The idea is that authors of proc macros could use these variables and based on them change behavior of the macro to provide a better (possible custom) completion for IDE users

@vlad20012 vlad20012 self-assigned this Nov 11, 2022
@Undin
Copy link
Member

Undin commented Nov 11, 2022

Are these variables already taken into account by proc macro expander, or do we want to add this support in future?

@vlad20012
Copy link
Member Author

vlad20012 commented Nov 11, 2022

The idea is that authors of proc macros could use these variables (in the future) and based on them change behavior of the macro to provide a better (possible custom) completion for IDE users. I made a PoC version for html! macro from yew and it seems to work. I'm going to open a PR in yew repo and so start a discussion about custom completion in proc macros, but I think we should start with setting these envs on our side

Now the plugin sets these environment variables when expands a proc macro during completion:
`RUST_IDE_PROC_MACRO_COMPLETION=1`
`RUST_IDE_PROC_MACRO_COMPLETION_PLACEHOLDER=IntellijIdeaRulezzz`
@vlad20012 vlad20012 force-pushed the macro-add-proc-macro-ability-to-handle-completion branch from 8d223d8 to 2880471 Compare November 16, 2022 20:47
@vlad20012
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 18, 2022

Build succeeded:

@Dr-Emann
Copy link

Is it possible to do something like this for build scripts as well? If I have a build script that outputs a huge phf map, I think IDE performance could be improved by only building a much smaller map when built for IDE uses?

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

Successfully merging this pull request may close these issues.

3 participants