Skip to content

Proposal: color attributes using regular syntax coloring #4430

@georgewfraser

Description

@georgewfraser

Following up on #4400. Right now, Rust attributes are left as the default color. Both the TextMate grammar and the semantic coloring rules specify meta.attribute.rust, which has no effect. In the default Dark+ theme, they show up as plain white:

Screen Shot 2020-05-11 at 5 23 39 PM

To me, this seems like more of an oversight than an intentional choice. Now that semantic coloring is available, rust-analyzer is "taking ownership" of syntax coloring, so it makes sense to fix this here. What do other languages do?

C# attributes are colored with normal syntax coloring, with the surrounding brackets punctuation.squarebracket.open.cs, which is the default color in Dark+:

Screen Shot 2020-05-11 at 5 04 07 PM

Typescript decorators are colored with normal syntax coloring, with the @ symbol punctuation.decorator.ts, which is the default color in Dark+:

Screen Shot 2020-05-11 at 5 14 20 PM

Java annotations are colored with normal syntax coloring, with the @ symbol punctuation.definition.annotation.java, which is the default color in Dark+:

Screen Shot 2020-05-11 at 5 09 05 PM

Based on these precedents, I propose that we color the inner parts of Rust attributes with the normal syntax coloring rules, and the surrounding #[] as punctuation.attribute.rust, which will render as the default color in the builtin themes (as it does now).

LMK what you think @matklad

@aloucks FYI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions