Sublime Forum

Vary syntax color if line is highlighted

#1

Currently in the theme I’m using any syntax error has a red background with white text, which looks good. However when I move my cursor to that line, the line highlight color takes over. My line highlight is a light gray so now I have white text on a light gray background and it is really hard to read.

Is there any way to change the theme colors based off of if the line is highlighted. I was hoping there would be some scope I could hook into and target the element differently if there was a line highlight present.

Unfortunately the scope appears to always be the same (according to ScopeHunter):

No line highlight:
text.html.basic meta.tag.inline.any.html string.quoted.double.html invalid.illegal.bad-ampersand.html

Yes line highlight:
text.html.basic meta.tag.inline.any.html string.quoted.double.html invalid.illegal.bad-ampersand.html

I really want to take this entry:

<dict> <key>name</key> <string>Invalid</string> <key>scope</key> <string>invalid</string> <key>settings</key> <dict> <key>background</key> <string>#C82829</string> <key>fontStyle</key> <string></string> <key>foreground</key> <string>#FFFFFF</string> </dict> </dict>

And make it something like:

		<dict>
			<key>name</key>
			<string>Invalid with line highlight</string>
			<key>scope</key>
			<string>line_highlight invalid</string>
			<key>settings</key>
			<dict>
				<key>foreground</key>
				<string>#C82829</string>
			</dict>
		</dict>

But I don’t know what to put in for the scope or if it is even possible. Anyone know if what I want to do can be done?

0 Likes

#2

you could write a plugin which would react to on_selection_modified event, check if the cursor is in a scope (via view.extract_scope) and if so place a accordingly styled region (via view.add_regions).

0 Likes