How to Get Ruby Syntax Highlighting in PHPstorm

Is it possible to get Ruby syntax highlighting in PHPStorm?

Ruby plug-in that you have linked is designed for IntelliJ IDEA Ultimate only, it will not work with PhpStorm. See this answer for more details.

However, it's possible to get the basic syntax highlighting for Ruby files in PhpStorm using the TextMate bundles support plug-in. It's already included with PhpStorm 6.0.1 and you don't need to install it, just make sure it's enabled in Settings | Plugins.

  1. Git clone Ruby.tmbundle into some directory.

  2. Add this directory in Settings | TextMate Bundles:

Ruby bundle

For some reason PhpStorm TextMate Bundles support will not recognize *.rb files as supported by this bundle. To fix this problem open Ruby.tmbundle\Syntaxes\Ruby.plist file in some text editor, find <key>fileTypes</key> section, add <string>rb</string> under <array>

(the above should be fixed in the latest Ruby bundle version, so the editing the bundle is no longer needed, but if you are adding some other language bundle, it's something you may need to adjust)

Restart PhpStorm, verify that *.rb is now associated correctly:

association

Now you get Ruby syntax highlighting in PhpStorm:

Ruby syntax


If you need full support for both Ruby and PHP (plus much more) in a single IDE, consider using IntelliJ IDEA Ultimate.

Ruby syntax highlighting in PyCharm?

You can either create a new file type in Settings/File Types, add .rb as registered pattern there, and define your own syntax highlighting rules, or search for existing textmate bundles for Ruby files in the web, import them and use for syntax highlighting - see http://blog.jetbrains.com/phpstorm/2013/05/textmate-bundles-in-phpstorm/ and https://stackoverflow.com/a/16451778/2000323 for more info

Velocity syntax highlighting in WebStorm

Since it is not supported in WebStorm yet I would suggest associating .vm files with xhtml.
You can do that by opening the search action dialog (cmd+shift+a in mac) and searching for associate with file type. Then choose the xhtml format.
It will not highlight all the velocity related code correctly but it is the best available solution.

WebStorm and PHP syntax highlighting in WebStorm

https://github.com/textmate/php.tmbundle bundle uses non-documented 'injection' - feature that's not currently supported - thus no highlighting is actually recognized. See RUBY-14273

Enabling Liquid templating syntax highlight in webStorm/phpStorm

I've found out that Twig have a very similar syntax to Liquid, enabling the Twig plugin will highlight Liquid syntax and will keep the HTML highlight/autocomplete/emmet functionality working as opposed to the "textMate Liquid bundle".

Go to Settings > Editor > File Types find "Twig" on that list and associate Liquid files with it by adding *.liquid to the registered patterns section.

If you can't find Twig, download the official plugin from the "Browse repositores" or in the "install JetBrains plugin". If you can't find it there then download the plugin and install it manually by pressing "install plugin from disk": https://plugins.jetbrains.com/plugin/7303?pr=

You will also want to associate *.scss.liquid to .scss files,
*.css.liquid to .css files and *.js.liquid to .js files so that Twig wouldn't run on those type of files.

The end result works like a charm! it's the best solution yet until some official plugin will come out, hope it helps someone.

Adding JSON syntax highlighting to IntelliJ IDEA for .liquid files

As @yole have said: you cannot do that. Well... permanently.

You can always inject JSON there manually .. and it will last for a while (a session for sure).

Just place caret just after {% schema %} and hit Alt + Enter.

Sample Image

Choose Inject language or reference and locate JSON in the list (speed search works there as well, so just start typing).

Sample Image

Result is obvious:

Sample Image


You are using Twig plugin for .liquid files (native support for them (RUBY-7210) does not seem to be on JetBrains short list right now).

It's now possible to have permanent Language Injection in custom Twig tag (using Twig plugin). See the screenshot below for custom injection rule that you can create yourself:

Sample Image

Syntax Highlighting

HTML/CSS/JavaScript based syntax highlighter solutions are the most popular and work well with different server technologies including Ruby.

  • SyntaxHighlighter (RECOMMENDED) is here to help a developer/coder to post code snippets online with ease and have it look pretty. It's 100% Java Script based and it doesn't care what you have on your server.

  • Syntax highlighting library for various languages at Rubyforge.org. Has built-in support for converting source code to syntax-highlighted HTML.

  • SyntaxHighlighter for WordPress. It allows you to easily post syntax highlighted code all without losing its formatting or making an manual changes.

  • Prettify. A Javascript module and CSS file that allows syntax highlighting of source code snippets in an html page.

  • GeSHi - Generic Syntax Highlighter. GeSHi started as an idea to create a generic syntax highlighter for the phpBB forum system, but has been generalised to this project. GeSHi aims to be a simple but powerful highlighting class, with the following goals: (1) Support for a wide range of popular languages (2) Easy to add a new language for highlighting (3) Highly customisable output formats

  • JUSH is a syntax highlighting component written in JavaScript. It highlights HTML, CSS, JS, PHP and SQL code embedded into each other. Beside syntax highlighting, it provides links to the documentation for all supported languages.

  • SyntaxHighlighter for Windows Live Writer at CodePlex.com (just in case :)

And here a few blog posts on the subject:

  • Syntax Highlighting for Ruby Made Very Easy
  • Syntax highlighting in Ruby


Related Topics



Leave a reply



Submit