Home Download Buy Blog Forum Support

Change color of end of line semicolons?

Change color of end of line semicolons?

Postby Paul on Mon Jul 19, 2010 7:00 pm

Is there a way to make it so that semicolons at the end of the line can be a specific color? I am a bit familiar with the tmTheme files, I edited colors in one already, but I was wondering if it would be possible to add this a theme file.

EDIT: Note, I only want semicolons at the end of a line, not all semicolons (because of string operation functions using a semicolon, I don't need those ones to stand out).

Thanks!
Paul
 
Posts: 6
Joined: Sun Jul 18, 2010 2:58 am

Re: Change color of end of line semicolons?

Postby tgkeul on Tue Jul 20, 2010 3:44 pm

You have to make a rule in your tmLanguage file for semicolons at the end of the line.
With the name of this rule you can assign a color in your tmTheme file
tgkeul
 
Posts: 140
Joined: Tue Dec 02, 2008 9:35 pm

Re: Change color of end of line semicolons?

Postby Paul on Fri Jul 23, 2010 6:18 pm

Do you have any idea on how to implement that?
Paul
 
Posts: 6
Joined: Sun Jul 18, 2010 2:58 am

Re: Change color of end of line semicolons?

Postby guillermooo on Fri Jul 23, 2010 6:56 pm

IMO, syntax files are a bit of pain in the neck to edit, because they are in xml, but it must be said that they are pretty straightforward too.

This might work for your case:

Code: Select all
<dict>
   <key>match</key>
   <string>;$</string>
   <key>name</key>
   <string>your.scope.selector.yourlanguagename</string>
</dict>


Now you'd need to:

1) Insert this snippet into the <array> of <patterns> in your tmLanguage file.
2) Edit the scope selector with the appropriate information. To get an idea how it works, copy a selector from an element that stands out from the rest of the code (comments, error warnings, etc). Scope selectors determine how the text is styled (according to other rules you can define too) besides, well, the scope of the pattern (basically, how far it spans).

I'm writing all this off the top of my head, so YMMV, but this is the gist of it.

If you want to develop a new syntax file, you might want to try my GrammarDev package, which should let you write your syntax file in json and do the conversion into xml automatically.

http://bitbucket.org/guillermooo/grammardev

Order matters, etc. Syntax files can be a little tricky in the beginning.

Check out the Macromates docs for more info!
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Change color of end of line semicolons?

Postby tgkeul on Fri Jul 23, 2010 7:21 pm

Some small additions to the very good post from guillermoo.
  • If you insert the code in an existing tmLanguage file it might not show an effect as other entries may overlay it. I experienced this in text.tmLanguage with meta.paragraph.text (order did not matter),
  • Use ctr+alt+p to display the scope in the statusline.
  • To see results from a changed tmLanguage file I have to restart the editor.
tgkeul
 
Posts: 140
Joined: Tue Dec 02, 2008 9:35 pm

Re: Change color of end of line semicolons?

Postby GreyWyvern on Tue Jul 27, 2010 5:15 pm

Do you mean end-of-line semi-colons or end-of-statement? For example, what if you do this?

Code: Select all
var foo = "string"; // comment


Or this?

Code: Select all
var foo = "string"; var baz = 42;


Or even this?

Code: Select all
var foo = "multiline;
string";


Not sure what language you are coding this for.
GreyWyvern
 
Posts: 106
Joined: Fri Oct 23, 2009 7:08 pm
Location: Canadia

Re: Change color of end of line semicolons?

Postby Paul on Thu Aug 05, 2010 9:27 pm

I was working in PHP, although it would apply for many languages. If you go through your examples, each semicolon fits what I was thinking. Basically, I was thinking a way to help one find an error caused by a missing semicolon. I know I wasn't very specific originally, but that is what I had thought. If those semicolons were obvious, it would be easy to find missing ones.

GreyWyvern wrote:Do you mean end-of-line semi-colons or end-of-statement? For example, what if you do this?

Code: Select all
var foo = "string"; // comment


Or this?

Code: Select all
var foo = "string"; var baz = 42;


Or even this?

Code: Select all
var foo = "multiline;
string";


Not sure what language you are coding this for.
Paul
 
Posts: 6
Joined: Sun Jul 18, 2010 2:58 am


Return to General Discussion

Who is online

Users browsing this forum: Majestic-12 [Bot] and 22 guests