Home Download Buy Blog Forum Support

Matching multiple scopes in color syntax

Matching multiple scopes in color syntax

Postby quodlibet on Fri Apr 13, 2012 12:39 pm

I'm working on a color syntax and I want to select all markdown punctuation. I know I can comma-separate multiple scopes, but I was hoping there might a wildcard I could use.

Something like:

Code: Select all
"scope": "punctuation.*.markdown"


Rather than the monstrosity I'm using right now:

Code: Select all
"scope": "punctuation.definition.blockquote.markdown, punctuation.definition.bold.markdown, punctuation.definition.constant.begin.markdown, punctuation.definition.constant.end.markdown, punctuation.definition.constant.markdown, punctuation.definition.heading.markdown, punctuation.definition.italic.markdown, punctuation.definition.link.markdown, punctuation.definition.list_item.markdown, punctuation.definition.metadata.markdown, punctuation.definition.raw.markdown, punctuation.definition.string.begin.markdown, punctuation.definition.string.begin.markdown, punctuation.definition.string.end.markdown, punctuation.definition.string.end.markdown"


Alex
quodlibet
 
Posts: 553
Joined: Sat Jun 18, 2011 5:53 pm

Re: Matching multiple scopes in color syntax

Postby facelessuser on Fri Apr 13, 2012 1:58 pm

What are you trying to do? I think you might be going down the wrong road, maybe not. But I need to understand what you are doing in order to help.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: Matching multiple scopes in color syntax

Postby handycam on Fri Apr 13, 2012 2:39 pm

See what the top lever is, then you can do something like:

Code: Select all
text.html.markdown punctuation.definition


This will color all those items that start that way. Adding text.html.markdown limits it to that type of document only.

I am assuming this is in the tmTheme file? If this is the tmLanguage file, ignore this, I'm not sure what you're doing.
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Matching multiple scopes in color syntax

Postby quodlibet on Fri Apr 13, 2012 3:08 pm

@handycam Thanks, that's exactly what I was looking for!

Sorry for confusing you guys. I should have mentioned I was working on a tmTheme.

Alex
quodlibet
 
Posts: 553
Joined: Sat Jun 18, 2011 5:53 pm

Re: Matching multiple scopes in color syntax

Postby nick. on Fri Apr 13, 2012 4:07 pm

I do wish the wildcard worked though; I've had a similar situation where I wanted only a specific language to have the styling applied.
Sure punctuation.definition does the trick but it does so for ALL languages, not just for Markdown as punctuation.*.markdown would do.
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: Matching multiple scopes in color syntax

Postby quodlibet on Fri Apr 13, 2012 4:20 pm

@nick. Look at @handycam's post again. To select all punctuation in markdown you would use: `text.html.markdown punctuation.definition`
quodlibet
 
Posts: 553
Joined: Sat Jun 18, 2011 5:53 pm

Re: Matching multiple scopes in color syntax

Postby nick. on Fri Apr 13, 2012 4:46 pm

Aha, I missed that, thanks! I had just assumed the space was akin to a CSS comma to style multiple scopes at once.
It makes sense that it references the hierarchy, given how the scope names appear using Ctrl+Alt+Shift+P.
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: Matching multiple scopes in color syntax

Postby quodlibet on Fri Apr 13, 2012 4:56 pm

Now if only there was a way to use variables in .tmThemes...

EDIT: I mean for colors
quodlibet
 
Posts: 553
Joined: Sat Jun 18, 2011 5:53 pm

Re: Matching multiple scopes in color syntax

Postby nick. on Fri Apr 13, 2012 7:00 pm

Would be easy enough to implement a parser in the existing syntax generating plugins.
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 20 guests