Home Download Buy Blog Forum Support

Syntax colour for ST API

Re: Syntax colour for ST API

Postby agibsonsw on Mon Mar 12, 2012 2:53 am

.. in fact, I might just make everything orange and be done with it :lol: ;) - it will remind me of a simpler time. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Syntax colour for ST API

Postby facelessuser on Mon Mar 12, 2012 4:01 am

agibsonsw wrote:.. in fact, I might just make everything orange and be done with it :lol: ;) - it will remind me of a simpler time. Andy.


:)

I have to admit, I understand what you mean. Digging around in these tmLanguage files isn't that fun...with all of the regex, and ensuring the proper order of definitions, and the recursion...
facelessuser
 
Posts: 1567
Joined: Tue Apr 05, 2011 7:38 pm

Re: Syntax colour for ST API

Postby agibsonsw on Mon Mar 12, 2012 5:11 pm

I realise that I'm opening myself up to mockery, but I welcome criticism of the attached screenshot :)

My view (excuse the pun..) on this topic is:

Every character should be legible;
There shouldn't be too harsh a contrast between any of the colours;
Important marker words, like 'class' and 'def', should be more pronounced;
Comments should seep into the background, but remain legible.

Andy.
Attachments
sublime_selected5.png
sublime_selected5.png (32.62 KiB) Viewed 716 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Syntax colour for ST API

Postby facelessuser on Mon Mar 12, 2012 5:33 pm

:shock:

Not my taste, but it looks like you are getting the hang of the tmLanguage files. The important thing is that it works for you :) .
facelessuser
 
Posts: 1567
Joined: Tue Apr 05, 2011 7:38 pm

Re: Syntax colour for ST API

Postby agibsonsw on Mon Mar 12, 2012 5:42 pm

facelessuser wrote::shock:

Not my taste, but it looks like you are getting the hang of the tmLanguage files. The important thing is that it works for you :) .


:lol: Yes, it is significantly different to your earlier screenshot!

For my further education, could you/someone describe in brief the difference between 'match' and 'captures' in tmLanguage? And what is the purpose of 'includes' please?

Regards, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Syntax colour for ST API

Postby facelessuser on Mon Mar 12, 2012 5:59 pm

The whole file is parsed by the regex definitions. As soon as a chunk of code is processed with a definition, the syntax parser moves on and that chunk of code will not be touched again.

Matches: matches your regex and assigns it your scope to group0 only (if one is provided) and moves on.

Captures: allow you to capture the specific groups and assign scopes to each group and also the entire match if desired. This example from python assigns group 1 a scope, but the entire match (group 0) has no no scope assigned to it.

Code: Select all
      <dict>
         <key>captures</key>
         <dict>
            <key>1</key>
            <dict>
               <key>name</key>
               <string>storage.modifier.global.python</string>
            </dict>
         </dict>
         <key>match</key>
         <string>\b(global)\b</string>
      </dict>


Begin/End Captures: Allow you to give a start capture and and end capture (as I understand, the end capture and reference the begin capture with lookaheads etc. and I think vice versa), but then it also allows you to then provide regex for the content between the Begin and End. You can even do recursion as I understand.
facelessuser
 
Posts: 1567
Joined: Tue Apr 05, 2011 7:38 pm

Re: Syntax colour for ST API

Postby agibsonsw on Mon Mar 12, 2012 6:14 pm

Thanks. 'includes' ?

Am I mistaken, or does ST not recognise regex-lookbehinds? I tried and it seemed to fail.

BTW I'm tempted to try and colour braces ( ), but I think I would be in for a world of pain :o

Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Syntax colour for ST API

Postby facelessuser on Mon Mar 12, 2012 6:54 pm

Oh yeah, includes. You can usually have a repository section in your tmLanguage and you give the definition key names. Then you can include the definition by its key name. Also, languages included other sources. You can see in things like the HTML language they will include "source.js" to pull in javascript tmLanguage file. It might be more powerful than that, but that is what I understand at this point.
facelessuser
 
Posts: 1567
Joined: Tue Apr 05, 2011 7:38 pm

Re: Syntax colour for ST API

Postby agibsonsw on Mon Mar 12, 2012 7:27 pm

Mmmm lot to learn ;)

The more I look at 'Python.tmLanguage' the messier it appears. There is a large collection of standard functions not listed. Also, a word like 'set' is used in a number of contexts, so it's difficult to distinguish the ST-API version. And datetime is both a module(object) and an object, etc.

I think I'll try and move on to something else for a while. Regards, Andy ;)
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Syntax colour for ST API

Postby quodlibet on Sun Apr 01, 2012 1:08 pm

agibsonsw wrote:Am I mistaken, or does ST not recognise regex-lookbehinds? I tried and it seemed to fail.


If you still haven't worked this out, you need to escape the "less than" sign. E.g., (?<=\W) should read (?&lt;=\W)

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

PreviousNext

Return to Technical Support

Who is online

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