Rust-analyzer: Semantic highlighting rule for visibility, fn declarations

Created on 11 May 2020  Â·  3Comments  Â·  Source: rust-analyzer/rust-analyzer

Before the release today, I was using the following:

"textMateRules": [
  {
    "scope": "keyword.control",
    "settings": {
      "foreground": "#c3e88d",
    }
  }
]

With today's update, it looks like this doesn't match. This isn't terribly surprising, given pub(crate) fn has nothing to do with control flow. However, there doesn't appear to be a replacement for this.

All 3 comments

Should be keyword.other---same as it was before semantic coloring. Also, you can now customize coloring using semantic rules, for example:

"editor.semanticTokenColorCustomizations": {
    "[Default Dark+]": {
        "rules": {
            "keyword": "#c3e88d"
        }
    }
}

But using a textmate rule is probably better, because it will apply to both the textmate rule (which is visible when you first open a file) and the semantic rule (which is visible when semantic coloring kicks in).

(in case you're wondering, yes, having the semantic token "keyword" map to the textmate scope "keyword.other" is the appropriate choice. TextMate scopes are very crufty)

Yeah, looks like semantic coloring overrides the regular TextMate for keyword.

Not sure how I didn't run into the semantic keyword earlier — I was/am aware of the different rules for semantic tokens.

Thanks for the response! This does work as expected :slightly_smiling_face:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kjeremy picture kjeremy  Â·  4Comments

matklad picture matklad  Â·  3Comments

kbarros picture kbarros  Â·  4Comments

Matelasse picture Matelasse  Â·  3Comments

AlseinX picture AlseinX  Â·  3Comments