Home Download Buy Blog Forum Support

For the tmLanguage gurus, a question

For the tmLanguage gurus, a question

Postby handycam on Mon Jun 11, 2012 12:42 am

I'm trying to make a change to the SCSS language file to correctly color a nested include in a Susy scss file

As in
Code: Select all
@include at-breakpoint(900 12) {
    @include susy-grid-background;


The current code only "closes" the previous scope when it hits a ; apparently. How can I edit the below code to also end at a {

Code: Select all
<key>end</key>
<string>\s*((;)|(?=\}))</string>
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: For the tmLanguage gurus, a question

Postby handycam on Mon Jun 11, 2012 12:44 am

I think I've got it:

Code: Select all
<string>\s*((;)|(?=\})|(\{))</string>


Correct? Seems to work.
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: For the tmLanguage gurus, a question

Postby handycam on Mon Jun 11, 2012 12:45 am

If I make edits like these, do I just edit the tmLanguage file in place, or make a copy in my user folder, or what's the safe procedure?
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: For the tmLanguage gurus, a question

Postby handycam on Mon Jun 11, 2012 1:10 am

The only thing that's still not 100% correct is that the semicolon and the bracket at the end of the line is included in the scope, and is gold in my theme, when other ; and { are white...

Screen Shot 2012-06-10 at 8.56.03 PM.png
Screen Shot 2012-06-10 at 8.56.03 PM.png (20.64 KiB) Viewed 2122 times
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: For the tmLanguage gurus, a question

Postby atomi on Mon Jun 11, 2012 2:14 am

I think you only need this:
Code: Select all
<key>end</key>
<string>(?=[;{])</string>
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: For the tmLanguage gurus, a question

Postby handycam on Mon Jun 11, 2012 12:16 pm

atomi wrote:I think you only need this:
Code: Select all
<key>end</key>
<string>(?=[;{])</string>


Indeed, thanks. Can you please translate?
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: For the tmLanguage gurus, a question

Postby quarnster on Mon Jun 11, 2012 12:26 pm

(?=...) is a look ahead expression, meaning that it matches if ... matches next, but doesn't make ... part of the match. See http://www.regular-expressions.info/lookaround.html
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: For the tmLanguage gurus, a question

Postby handycam on Mon Jun 11, 2012 12:51 pm

quarnster wrote:(?=...) is a look ahead expression, meaning that it matches if ... matches next, but doesn't make ... part of the match. See http://www.regular-expressions.info/lookaround.html


Thank you. I've never used look-aheads before, I will start now!
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: For the tmLanguage gurus, a question

Postby nick. on Mon Jun 11, 2012 3:43 pm

Be aware that some features are missing from the regex parser for syntax definitions. Here is the documentation. Notably absent are conditionals.
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: For the tmLanguage gurus, a question

Postby ILikeVoltron on Tue Jan 29, 2013 9:51 pm

Re-opening this old thread with a very very similar question.

I'm using the below regex to match just the (\w+), not the whole line. I'm doing this with a (?:...) as described in the documentation as a "not captured group" but I've also tried the previously mentioned (?=...) as well with similar failures.

Code: Select all
      <dict>
         <key>match</key>
         <string>(?:object network) (\w+)</string>
         <key>name</key>
         <string>keyword.network.object.cisco</string>
      </dict>


The above code matches the entire line below:

Code: Select all
object network myInsideNetwork


How can I apply the keyword.network.object.cisco style to just the (\w+) and not the whole line?
ILikeVoltron
 
Posts: 6
Joined: Mon Jan 28, 2013 6:26 am


Return to General Discussion

Who is online

Users browsing this forum: subhaze and 16 guests