Sublime Forum

Changing Text Colour With Plugin

#1

Hi all,

I want to make a syntax highlighter which I don’t think regex alone will allow, and therefore I believe a plugin is necessary. As far as I can tell I can only outline/fill/underline blocks. Can this be done with phantoms? I couldn’t get them to work at all.

Any help much appreciated, cheers
Joe

0 Likes

#2

you can achieve quite a lot using .sublime-syntax files - they are not just regex, you crn make use of coetexts to track state

correct, plugins can’t affect foreground colors

I still think you’re better off using a syntax definition, using phantoms would be weird with duplicated text

1 Like

#3

Well, I’ll give it a go, but given there are no good C++ syntax highlighters that I can find, I assumed the syntax highlighted system was too limited.

0 Likes

#4

what don’t you like about the default C++ syntax highlighting in build 3126?

0 Likes

#5

It only seems to recognise known integral types like int/bool etc as types. I’d like it to make an assumption that if I write “SomeCustomType some_variable;” then SomeCustomType is a type, and some_variable is a variable.

0 Likes

#6

That’s not a trivial task… you’d need a compiler to give you that information. For instance, a::b() could mean call the function b in namespace a, or call the static function b in class a, or instantiate a default constructed object of class b in namespace a, etc.

On the other hand, you may be able to hack it in in a sublime syntax file with the assumptions that you state.

0 Likes

#7

I’d rather make assumptions and get something that isn’t always correct, rather than the frankly poor syntax highlighting we get.

0 Likes

#8

And the example I gave is fairly trivial “Type variable;”, I agree other things are more complicated, e.g A::B, B could be a type or an enum value.

0 Likes