Sublime Forum

C# tmLanguage help!

#1

Hello, New user here although I have been enjoying SublimeText3
for a long time now. A preface to my issue is that I am terrible
with Regular Expressions, and I have been having a crazy time trying
to get this to work.

Anyway I have used PackageResourceManager to extract and modify my
C#.tmLanguage & Monokai.tmTheme files to try and add something simple.
(or so I thought)

All I want is for the semicolon (:wink: to denote end of statements to
be highlighted in orange(#E5C100)

This has proved to be a difficult task.

so far, I have tried many different things, and tried pasting the
code block in different patterns sections of the tmLanguage file,
but that either doesnt change anything or breaks the whole file.

I’ve tried changing the scope as well, but when I do that even changing
the corresponding scope in the tmTheme seems to make it not work at all.

anyways sorry for the wall of text, heres the code I have for the
tmLanguage file

[quote]C#.tmLanguage:19

match
\z(;)|);|;$
name
semicolon.cs

[/quote]

Which is placed just after the first array after the patterns tag

The corresponding tmTheme, placed right before the ending array & uuid;

[quote]Monokai.tmTheme:392

name
semicolon
scope
semicolon
settings[/quote]

foreground #E5C100

This kind of works, but it doesn’t work inside of classes, or more specifically,
inside anything that is wrapped with a curly brace. (which is most of the code)

For Example

[quote]HelloWorld.cs
using System;
class HelloWorld
{
static void Main()
{
//Use the System Console object
Console.WriteLine("Hello World! "); //<-Here is where I need it to be #E5C100

}

}
//something outside of classes will work, even though this syntax is incorrect
private static string OutsideCurlys;
[/quote]

I am at a loss trying to figure this out, I have searched online extensivley
to try and find a solution or a pre made .tmLanguage file that will work,
but is nowhere to be found.

I have a thought that the problem might be somewhere in the Regexp on line 158 of C#.tmLanguage

[quote]C#.tmLanguage:158
begin
(^;]?=\w?\w\s]*(?:class|struct|interface|enum)\s+\w+)
end
}
endCaptures
[/quote]

But I don’t know exactly how to modify that particular Regexp without messing up other functionality.

Anyone who took the time to read this post I applaud you and extend my greatest gratitude
for anyone who might be able to help me with this. I know it’s something small
and rather insignificant but I am OCD like this and I think it would be easier
for debugging if I happen to miss a (:wink: it would be easier to notice with
it highlighted.

If there is no solution to this problem then so be it but I thought I would
reach out to a community and see what someone else might have to say about it.
Thanks again and have a great day, sorry for the wall of text again.

0 Likes