Home Download Buy Blog Forum Support

Color Scheme Help

Color Scheme Help

Postby saulhudson on Mon Jun 17, 2013 1:10 pm

Hi All

I'm just starting to create my own color scheme for ST2 and I've come up against a slight problem. For markup languages I'm trying to color the attribute differently to the tag. Which I've done like this ...

Code: Select all
      
<dict>
         <key>name</key>
         <string>Tag Name</string>
         <key>scope</key>
         <string>entity.name.tag, meta.tag, declaration.tag</string>
         <key>settings</key>
         <dict>
            <key>foreground</key>
            <string>#32665F</string>
         </dict>
      </dict>
      <dict>
         <key>name</key>
         <string>Tag attribute</string>
         <key>scope</key>
         <string>entity.other.attribute-name</string>
         <key>settings</key>
         <dict>
            <key>foreground</key>
            <string>#64A59C</string>
         </dict>
      </dict>


However for something like <table class="someClass"> this colors the "=" equals sign the same color as the tag name and I'd like it to either be a different color altogether or the same color as the attribute.

Is there anyway I can set the color the equals sign specifically or make the same as the attribute and attribute value?

Many thanks
saulhudson
 
Posts: 1
Joined: Mon Jun 17, 2013 1:02 pm

Re: Color Scheme Help

Postby FichteFoll on Mon Jun 24, 2013 1:40 pm

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):

Code: Select all
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. "<a height=12>") but still, works fine most of the time.

Here is what my definition looks like (in YAML):
Code: Select all
- 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.
FichteFoll
 
Posts: 388
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Color Scheme Help

Postby brendn478 on Mon Jun 24, 2013 4:08 pm

Oh yeah! I got it working. It wasn't that hard to follow, just takes a few tries though. Thank you so much for the help with this one!
Please click here for more info.

Read more information about marketing ideas.
brendn478
 
Posts: 2
Joined: Mon Jun 24, 2013 11:10 am


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 16 guests