Sublime Forum

For the tmLanguage gurus, a question

#1

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

@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 {

<key>end</key>
<string>\s*((;)|(?=\}))</string>
0 Likes

#2

I think I’ve got it:

<string>\s*((;)|(?=\})|(\{))</string>

Correct? Seems to work.

0 Likes

#3

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?

0 Likes

#4

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…


0 Likes

#5

I think you only need this:

<key>end</key>
<string>(?=;{])</string>
0 Likes

#6

[quote=“atomi”]I think you only need this:

<key>end</key> <string>(?=;{])</string> [/quote]

Indeed, thanks. Can you please translate?

0 Likes

#7

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

0 Likes

#8

Thank you. I’ve never used look-aheads before, I will start now!

0 Likes

#9

Be aware that some features are missing from the regex parser for syntax definitions. Here is the documentation. Notably absent are conditionals.

0 Likes

#10

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.

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

object network myInsideNetwork

How can I apply the keyword.network.object.cisco style to just the (\w+) and not the whole line?

0 Likes