Flip
Flip

Reputation: 6761

How to add syntax highlighting for custom methods in Atom for Ruby

For example, in the following class, I want syntax highlighting for helper_method(@x, @y) (line 1 in the main method.)

class test
  def new(x, y)
    @x = x
    @y = y
  end

  def main
    result = helper_method(@x, @y)
    puts result
  end

  def helper_method(x, y)
    // do stuff with x, y
  end
end

I wonder why the current highlighting scheme doesn't do that as it seems valuable to me to see where I call my methods and where I just use baked-in commands and expressions. Can I change that, for Atom?

Here some screenshots to further illustrate my problem:

In the first screenshot I expect get_time_limit_for_source(order_source) to be highlighted:

enter image description here

It is a method that is defined in the same class:

enter image description here

Interestingly, in my example code, the highlighting is exactly as I want it:

enter image description here

The highlighting in the test class is as I want it, but in this case is due to the use of the helper word which triggers highlighting when language-ruby-on-rails is installed/activated.

Upvotes: 2

Views: 602

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121000

Atom is an Electron app, based on Chrome. Feel free to press Ctrl+Shift+I and examine whatever you want with Chrome Developer Tools:

enter image description here

As you can see, the local method call is not granted with any class, therefore it is impossible to style it without patching the syntax highlighter. For those elements having the class[es], one might simply EditStylesheet in the main menu and update the CSS.

Upvotes: 3

Related Questions