sonph / onehalf

Clean, vibrant and pleasing color schemes for Vim, Sublime Text, iTerm, gnome-terminal and more.
MIT License
1.78k stars 236 forks source link

Unable to get proper syntax highlighting for member variables and member functions in VS Code #84

Open rchoudhary opened 4 years ago

rchoudhary commented 4 years ago

I have the following C++ code snippet colored using the default Light+ theme:

enter image description here

To achieve it, all I needed to add to settings was

    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "variable.other.local",
                "settings": {
                    "foreground": "#0000FF",
                    "fontStyle": "italic bold underline"
                }
            }
        ]
    },

Local variables are black, member variables are dark blue, and member functions are dark gold. Even in a chain of calling, member variables and member functions are highlighted appropriately.

However, when I use the OneHalf Light with the same setting as above, I get the following:

enter image description here

The member variable in the class itself is uncolored, member and local variables are colored the same, and the declaration of local variables is uncolored. Only member functions are appropriately colored.

For some reason, the variable.other.local property is ignored.

Here is the closest I can get:

    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "variable.other",
                "settings": {
                    "foreground": "#0000FF",
                    "fontStyle": "italic bold underline"
                }
            },
            {
                "scope": "variable.other.local",
                "settings": {
                    "foreground": "#FF00FF",
                    "fontStyle": "italic bold underline"
                }
            },
            {
                "scope": "variable.other.property",
                "settings": {
                    "foreground": "#FF0000",
                    "fontStyle": "italic bold underline"
                }
            },
            {
                "scope": "entity.name.function",
                "settings": {
                    "foreground": "#00CC00",
                    "fontStyle": "italic bold underline"
                }
            }
        ]
    }

Those configurations give me this:

enter image description here

So:

  1. entity.name.function seems to work correctly.
  2. variable.other.local is completely ignored.
  3. LHS usages of foo are captured by variable.other, but declarations are RHS usages are not.
  4. bar in the class definition is ignored by variable.other.property.
  5. If .bar is the last thing in a line, it is correctly colored by variable.other.property.
  6. If .bar is in the middle of a line, it is ignored by variable.other.property and colored using variable.other.

For the sake of comparison, here is what those same rules look like using the Light+ theme:

enter image description here

It works exactly as expected!

Why would variable.other.local work for one theme but not another? It's my understanding that VS Code simply labels all words with a type and a theme simply decides what color each type should be. Is the theme somehow using a different syntax engine?