Domanda

Is there any editor with any color scheme in which:

BulkMailer.bulk_email recipient, body

bulk_email is highlighted in one color and the parameters are highlighted in a different color. I use Sublime Text 2 and I tried a lot of color schemes but so far none of them does that.

While this works when defining methods (here bulk_email has a different color):

def bulk_email(recipient, body)
  # some logic
end

I would like to have that also in method calls. I find this especially helpful, as Ruby allows for omitting the braces around parameter lists and in long lists it's sometimes a little slow to detect where the actual method call ends. As I mentioned, I don't insist on Sublime, any editor is fine.

È stato utile?

Soluzione

SynWrite editor (Windows) can do it.

Activate Ruby lexer, goto lexer properties dialog, create new Parser called ".name" to hilite names after a dot with a new color, and set parser's regex.
Result with hilited method name (with my changes in lexer): Ruby test

Altri suggerimenti

Here you go solution for Sublime Text 2

Ruby.tmLanguage (Add)

<dict>
    <key>captures</key>
    <dict>
        <key>1</key>
        <dict>
            <key>name</key>
            <string>entity.chained.name.function.ruby</string>
        </dict>
        <key>2</key>
        <dict>
            <key>name</key>
            <string>variable.chained.parameter.function.ruby</string>
        </dict>
        <key>3</key>
        <dict>
            <key>name</key>
            <string>comment</string>
        </dict>
    </dict>
    <key>match</key>
    <string>^.*\.(\w+)(.*?)(#.*)*?$</string>
    <key>name</key>
    <string>meta.function.method.with-arguments.ruby</string>
</dict>

In your Theme File (default is Monokai.thTheme) (Add)

<dict>
    <key>name</key>
    <string>Function name</string>
    <key>scope</key>
    <string>entity.chained.name.function</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>PUT A HEX COLOR VALUE HERE</string>
    </dict>
</dict>
<dict>
    <key>name</key>
    <string>Function argument</string>
    <key>scope</key>
    <string>variable.chained.parameter</string>
    <key>settings</key>
    <dict>
        <key>fontStyle</key>
        <string>italic</string>
        <key>foreground</key>
        <string>PUT A HEX COLOR VALUE HERE</string>
    </dict>
</dict>

this will cause the method name to be one color and the argumetns to be another and inline comments to match as comments.

Huge Caveats This was fun but I don't really feel like exploring further so here are some caveats that could be overcome with a much more complex regex. Highlights the following additional items that are probably not intended by your question.

1.Final Chain Methods Ending in alpha_numeric characters
2.Inline blocks with a space between called method and block
3.Multiline Block keywords and piped variables

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top