abusalimov/SublimeCImproved

Causes function calls to lose their highlighting

theanine opened this issue · 8 comments

Under Monokai and "C" style, function calls are highlighted in blue. Under Monokai and "C Improved" style, function calls remain white.

This is the intended behavior. Only special (a.k.a. support) functions are highlighted (like printf). Remaining are left as is.

I see. Is there some way to change this? Would be great if there was color settings somewhere.

Well, customizing syntax definition files is always a pain, I'm afraid the only way is to modify tmLanguage file directly. However, I believe that the current behavior should be left as is, to be consistent with syntax definitions of other languages, and to make the highlighting more informative by emphasizing library functions. So, I'm probably not going to change this, at least in the master.

To be clear, I would likely add an option for a user to be able to customize this, among with other highlighting aspects, if I could. But again, I don't know how to achieve this without doing some magic like generating tmLanguage on the fly.

If the highlighting really annoys you, you could fork the repo and change the regex that define a function call:

        <key>call</key>
        <dict>
            ...
                (?= # don't consume to recognize support functions
                    (?: [A-Za-z_]\w*+ | ::[^:] )++
                    (?:\s|/\*.*?\*/)*+ \( )

... to something like this:

                ((?: [A-Za-z_]\w*+ | ::[^:] )++)
                (?= (?:\s|/\*.*?\*/)*+ \( )

And add a pattern capturing that group and associating it, for example, with support.function.custom.c scope:

            <key>beginCaptures</key>
            <dict>
                <key>1</key>
                <dict>
                    <key>name</key>
                    <string>support.function.custom.c</string>
                </dict>
            </dict>

This should do the trick!

Awesome thanks, I'll do that. You may want to add that to some README or something.

You're welcome, thanks for reporting this.
OK, I'll consider mentioning the issue in Dropped features section of README, and I'll leave this open until I get some spare time to do that.

Thanks for C Improved. It's very useful!
On Feb 3, 2015 5:21 PM, "Eldar Abusalimov" notifications@github.com wrote:

You're welcome, thanks for reporting this.
OK, I'll consider mentioning the issue in Dropped features section of
README, and I'll leave this open until I get some spare time to do that.


Reply to this email directly or view it on GitHub
#11 (comment)
.

Done.

BTW, the default behavior is now reverted to highlight all function calls (as it used to be in the standard C package), so this issue can be considered as fixed.