Since the =
does not have a scope explicitly set you have to do it the other way around or just exclude everything else.
For your snippet <table class="someClass">
with cursors ("|")here: |<tab|le cla|ss|="some|Class">
I get the following (I wrote a small plugin for that but Ctrl+Alt+Shift+P works as well here):
line 1, col 1: text.html.basic meta.tag.inline.any.html punctuation.definition.tag.begin.html
line 1, col 5: text.html.basic meta.tag.inline.any.html entity.name.tag.inline.any.html
line 1, col 11: text.html.basic meta.tag.inline.any.html entity.other.attribute-name.html
line 1, col 13: text.html.basic meta.tag.inline.any.html
line 1, col 19: text.html.basic meta.tag.inline.any.html string.quoted.double.html
and col 13 is what we want to highlight. As you can see, it is the shortest scope so you could address “meta.tag” directly and let the other tags override it (foreground color only!) This introduces a problem with the “punctuation” angle brackets because they don’t have another color assigned to them which leaves them with the same color as the “=”.
Solution: Do an opt-out selector. Using a selector like meta.tag - (entity, punctuation, string)
we have essentially eliminated all the fuss about highlighting stuff we don’t want to highlight and are only left with our “=” and whitespaces (only visible when modifying the background color). And it will also highlight everything unquoted because the syntax definition does not take care of them (e.g. “”) but still, works fine most of the time.
Here is what my definition looks like (in YAML):
- name: Assignment "=" for HTML attributes
scope: meta.tag.inline.any.html - (entity, punctuation, string)
settings:
foreground: '#3609C4'
I hope this isn’t too clustered to follow.