+2

Highlight the colon as operator with Ruby 1.9-style hashes

Lance Ivy 5 years ago • updated 5 years ago 2

When both keys and values are symbols, the colors all run together. A simple fix would be to not consume the colon in the regular expression. I was able to accomplish this by changing "(:)(?!:)" to "(?=:)(?!::)", as in:


    <dict>

      <key>captures</key>

      <dict>

        <key>1</key>

        <dict>

          <key>name</key>

          <string>punctuation.definition.constant.ruby</string>

        </dict>

      </dict>

      <key>comment</key>

      <string>symbols</string>

      <key>match</key>

      <string>(?&gt;[a-zA-Z_]\w*(?&gt;[?!])?)(?=:)(?!::)</string>

      <key>name</key>

      <string>constant.other.symbol.ruby.19syntax</string>

    </dict>


I'm unsure where the downvote came from -- could anyone clarify? I've been using this for a while and have found it to be a definite improvement.