abusalimov / SublimeCImproved

(NO LONGER MAINTAINED) Improved syntax for C/C++/Objective-C, with a special support for sources of Linux kernel, CPython, etc.
https://packagecontrol.io/packages/C%20Improved
MIT License
51 stars 45 forks source link

Causes function calls to lose their highlighting #11

Closed theanine closed 9 years ago

theanine commented 9 years ago

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

abusalimov commented 9 years ago

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

theanine commented 9 years ago

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

abusalimov commented 9 years ago

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!

theanine commented 9 years ago

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

abusalimov commented 9 years ago

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.

theanine commented 9 years ago

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 https://github.com/abusalimov/SublimeCImproved/issues/11#issuecomment-72772555 .

abusalimov commented 9 years ago

Done.

abusalimov commented 9 years ago

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.