elixir-editors / language-elixir

Elixir language support for the Atom editor.
Other
181 stars 40 forks source link

Support for |> #17

Closed shadabahmed closed 8 years ago

shadabahmed commented 9 years ago

The most awesome operator in elixir should have its own highlighting. Right now it just looks plain:

image

rktjmp commented 9 years ago

There are two parts to this issue, elixir.cson and your themes stylesheet.

Support exists in elixir.cson#526, but it seems that regex for \| overrides the search for\|> (I guess because it matches first?). So the order has to be swapped around:

  {
    'match': '\\||\\+\\+|\\-\\-|\\*\\*|\\\\\\\\|\\<\\-|\\<\\>|\\<\\<|\\>\\>|\\:\\:|\\.\\.|\\|>|~|=>'
    'name': 'keyword.operator.other.elixir'
  }

to

  {
    'match': '\\+\\+|\\-\\-|\\*\\*|\\\\\\\\|\\<\\-|\\<\\>|\\<\\<|\\>\\>|\\:\\:|\\.\\.|\\|>|~|=>|\\|'
    'name': 'keyword.operator.other.elixir'
  }

Next, its unlikely that your theme is applying styling to keyword.operator, because this would style everything like +, -, =. If you add the following to your theme file, you'll see pipes being highlighted in red.

.keyword.operator{
  background: red;
}

I tried moving the matcher for |> into keywords.control, along with for, if etc, but the match fails. I think its possibly being broken other matches, but I'm not familiar enough with describing languages in Atom to know whats going on, there seems to be a few places that |> is matched, as well as the potential interference from matches related to a single pipe.

keathley commented 8 years ago

The |> operator should now be matched correctly. If you want to apply any alternative syntax highlighting to them you can use @rktjmp's suggestion or something similar.