8

I want to go further and style more things. For example I will like to style the following:

setting1 = 4
setting2 = 192.168.1.12
etc...

I will like to style everything to the left of the = blue and everything to the right purple.

The problem is that atom regex engine does not support negative look ahead or positive look ahead. As a result, I have tried using the begin and end directives but that still does not work. In other words I have tried:

{
  # section reference
  'begin': '^\\s*.*?=' # match a line that contains an = sign
  'end': '.+$' # continue until the end of the line
  'match': '^\\s*[^=]*'  #only match everything that is not an equal sign 
  'name': 'blue' #style it with the blue style
},

So basically, I need it to look like this:

enter image description here

Any ideas?

Community
  • 1
  • 1
Tono Nam
  • 34,064
  • 78
  • 298
  • 470

1 Answers1

3

I came up with this solution: (reules.cson)

'scopeName': 'source.conf'
'name': 'CONF'
'fileTypes': ['CONF']
'patterns': [     
  {
    # equality
    'match': '(?x) ^ ([^=;]+) (=)  (.+?)\\n'
    'captures':
      '1' :
        'name' : 'blue'
      '2' :
        'name' : 'yellow'
      '3' :
        'name' : 'purple'
  }

]

You can style every capture differently.

Tono Nam
  • 34,064
  • 78
  • 298
  • 470
  • An fyi: If you don't match `([^=;]+)`, a required amount of text, you can never match `(=) (.+?)` also required. And visa-versa. At minimum, you should change it to `'(?x) ^ ([^=;]+) (=) (.*)\\n?'`. –  Aug 24 '16 at 16:05