Sublime Text 3 Doesn't Recognize %i in ruby

ruby, sublimetext, sublimetext3

Solution

The `%i[foo bar] # [:foo :bar]` literal notation for a symbol array was only implemented in Ruby 2.0, while the Ruby language definition that ships with ST3 is mostly focused on 1.9 and earlier. I searched around a bit, but unfortunately I couldn't find any `.tmLanguage` files that are updated for 2.0, let alone include this literal notation, so I can't point you to a ready-made solution. But, I do have a few suggestions.

First, head over to the unofficial Sublime Text Issues tracker and post a bug report. We're not sure how much attention is paid to this list by the developer, but it at least broadens the issue's visibility and may prompt someone to post a fix. You can also reply to this thread on the Sublime Text forum and perhaps reference your issue.

The second option, if you have good regex-fu, is to hack the `Ruby.tmLanguage` file and add support yourself. I was going to post directions on how to do it, but then I tried it myself and it seemed to work, so feel free to use my work:

- Go to `Preferences -> Browse Packages` to open up the `Packages` folder in your system's file explorer.

- Create a folder called `Ruby2`.

- Copy the contents of this gist into a new file, and save it in your `Ruby2` directory as `Ruby2.tmLanguage`.

- Restart Sublime, switch to your problematic code, and select `View -> Syntax -> Ruby2`. Both lines should now be highlighted the same way. Here's a before and after screenshot using the Neon Color Scheme:

I hope this helps. I'm not a Rubyist, so if I made any blatant errors please let me know.

From my (brief) research there definitely seems to be a need for an updated version of `Ruby.tmLanguage` for all the new features in 2.0, so hopefully any issues you post will prompt someone to start/publish a project. I've already done something similar for Python, but my Ruby skillz just aren't there for this project :)

Good luck!

Problem

I'm using the latest build of Sublime Text 3. When typing `%i[foo bar]` Sublime does not seem to recognize this and I don't get the proper highlighting. Has anyone else experienced this? If so, is there a way I can fix this on my end or is this something that Sublime HQ would have to fix?

Original source