Skip to content

Color attribute functions #4474

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

Merged
merged 1 commit into from
May 24, 2020
Merged

Conversation

georgewfraser
Copy link
Contributor

Right now, only literals are colored within Rust attributes:

Screen Shot 2020-05-15 at 7 38 00 PM

To me, attributes look weirdly blank, and it seems like we should make some attempt to color them. I gathered some feedback on Zulip and in #4430. This PR colors the outer function that's present in every attribute as a function:

Screen Shot 2020-05-15 at 7 36 56 PM

I think this will be an uncontroversial improvement. I think it would also be popular if we colored type names in #[derive(TypeName)], and perhaps some other special cases, but this would require ad-hoc special cases in rust-analyzer, which might be controversial, so I'm starting with the most obvious improvements in this PR.

Fixes #4430

@Veetaha
Copy link
Contributor

Veetaha commented May 23, 2020

@matklad LGTM

@matklad
Copy link
Member

matklad commented May 24, 2020

bors r+

@@ -361,7 +361,9 @@ fn highlight_element(
}

// Highlight references like the definitions they resolve to
NAME_REF if element.ancestors().any(|it| it.kind() == ATTR) => return None,
NAME_REF if element.ancestors().any(|it| it.kind() == ATTR) => {
Highlight::from(HighlightTag::Function) | HighlightModifier::Attribute
Copy link
Member

@matklad matklad May 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, this gives a nicer looks, but semantically this feels wrong. Like, it's not a function, it's a part of attribute syntax.

Maybe we should introduce something like HighlightTag::AttrKey here? Not that it really matters though.

@matklad matklad merged commit ce7144a into rust-lang:master May 24, 2020
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

Successfully merging this pull request may close these issues.

Proposal: color attributes using regular syntax coloring
3 participants