Search code examples
visual-studio-codecrystal-lang

VS Code Highlight Text Mate Rules Priority


Is there a way to make the meta.function-call text mate rule to take precedence over entity.name.function?

In VS Code Crystal (Ruby-like language) setting both method definition and method call marked with the entity.name.function token.

I would like to have method definition as bold but method calls as not bold. But it doesn't work as I can't override entity.name.function with meta.function-call

enter image description here

My setting.json:

{
  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": [
          "entity.name.function"
        ],
        "settings": { "foreground": "#3730A3", "fontStyle": "bold" }
      },
      {
        "scope": [
          "meta.function-call"
        ],
        "settings": { "foreground": "#111827", "fontStyle": "" }
      }
    ]
  }
}

Solution

  • Specify multiple scopes delimited by whitespace:

    {
        "name": "function definition",
        "scope": [
            "entity.name.function"
        ],
        "settings": {
            "foreground": "#ff0000"
        }
    },
    {
        "name": "function call",
        "scope": [
            "meta.function-call entity.name.function"
        ],
        "settings": {
            "foreground": "#0000ff"
        }
    },