Last active
August 29, 2015 13:56
-
-
Save abe33/8843371 to your computer and use it in GitHub Desktop.
Enable color highlighting of Ruby, JavaScript, CoffeeScript and Sass source code within haml files in SublimeText
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Add the code below into your 'Ruby Haml.tmLanguage' file. | |
The file should be located in your sublime packages path. | |
If you don't have one, take the 'Ruby.sublime-package' file | |
from the 'Installed Packages' directory, change the file extension | |
to zip and extract it into your 'Packages' directory. | |
Edit: The previous version failed to match all the cases with a single begin/end pair. | |
This version uses two rules instead of one. One for embedded language that starts without | |
indent, and the other for indented blocks. | |
--> | |
<dict> | |
<key>begin</key> | |
<string>^(:ruby)$</string> | |
<key>beginCaptures</key> | |
<dict> | |
<key>1</key> | |
<dict> | |
<key>name</key> | |
<string>keyword.other.special-method.ruby</string> | |
</dict> | |
</dict> | |
<key>end</key> | |
<string>^(?=\S)</string> | |
<key>name</key> | |
<string>text.haml</string> | |
<key>patterns</key> | |
<array> | |
<dict> | |
<key>include</key> | |
<string>source.ruby</string> | |
</dict> | |
</array> | |
</dict> | |
<dict> | |
<key>begin</key> | |
<string>^(\s*)\s{2}(:ruby)$</string> | |
<key>beginCaptures</key> | |
<dict> | |
<key>2</key> | |
<dict> | |
<key>name</key> | |
<string>keyword.other.special-method.ruby</string> | |
</dict> | |
</dict> | |
<key>end</key> | |
<string>^(?!\1 |\n)|^(?=%|-)</string> | |
<key>name</key> | |
<string>text.haml</string> | |
<key>patterns</key> | |
<array> | |
<dict> | |
<key>include</key> | |
<string>source.ruby</string> | |
</dict> | |
</array> | |
</dict> | |
<dict> | |
<key>begin</key> | |
<string>^(:coffeescript)$</string> | |
<key>beginCaptures</key> | |
<dict> | |
<key>1</key> | |
<dict> | |
<key>name</key> | |
<string>keyword.other.special-method.ruby</string> | |
</dict> | |
</dict> | |
<key>end</key> | |
<string>^(?=\S)</string> | |
<key>name</key> | |
<string>text.haml</string> | |
<key>patterns</key> | |
<array> | |
<dict> | |
<key>include</key> | |
<string>source.coffee</string> | |
</dict> | |
</array> | |
</dict> | |
<dict> | |
<key>begin</key> | |
<string>^(\s*)\s{2}(:coffeescript)$</string> | |
<key>beginCaptures</key> | |
<dict> | |
<key>2</key> | |
<dict> | |
<key>name</key> | |
<string>keyword.other.special-method.ruby</string> | |
</dict> | |
</dict> | |
<key>end</key> | |
<string>^(?!\1 |\n)|^(?=%|-)</string> | |
<key>name</key> | |
<string>text.haml</string> | |
<key>patterns</key> | |
<array> | |
<dict> | |
<key>include</key> | |
<string>source.coffee</string> | |
</dict> | |
</array> | |
</dict> | |
<dict> | |
<key>begin</key> | |
<string>^(:javascript)$</string> | |
<key>beginCaptures</key> | |
<dict> | |
<key>1</key> | |
<dict> | |
<key>name</key> | |
<string>keyword.other.special-method.ruby</string> | |
</dict> | |
</dict> | |
<key>end</key> | |
<string>^(?=\S)</string> | |
<key>name</key> | |
<string>text.haml</string> | |
<key>patterns</key> | |
<array> | |
<dict> | |
<key>include</key> | |
<string>source.js</string> | |
</dict> | |
</array> | |
</dict> | |
<dict> | |
<key>begin</key> | |
<string>^(\s*)\s{2}(:javascript)$</string> | |
<key>beginCaptures</key> | |
<dict> | |
<key>2</key> | |
<dict> | |
<key>name</key> | |
<string>keyword.other.special-method.ruby</string> | |
</dict> | |
</dict> | |
<key>end</key> | |
<string>^(?!\1 |\n)|^(?=%|-)</string> | |
<key>name</key> | |
<string>text.haml</string> | |
<key>patterns</key> | |
<array> | |
<dict> | |
<key>include</key> | |
<string>source.js</string> | |
</dict> | |
</array> | |
</dict> | |
<dict> | |
<key>begin</key> | |
<string>^(:sass)$</string> | |
<key>beginCaptures</key> | |
<dict> | |
<key>1</key> | |
<dict> | |
<key>name</key> | |
<string>keyword.other.special-method.ruby</string> | |
</dict> | |
</dict> | |
<key>end</key> | |
<string>^(?=\S)</string> | |
<key>name</key> | |
<string>text.haml</string> | |
<key>patterns</key> | |
<array> | |
<dict> | |
<key>include</key> | |
<string>source.sass</string> | |
</dict> | |
</array> | |
</dict> | |
<dict> | |
<key>begin</key> | |
<string>^(\s*)\s{2}(:sass)$</string> | |
<key>beginCaptures</key> | |
<dict> | |
<key>2</key> | |
<dict> | |
<key>name</key> | |
<string>keyword.other.special-method.ruby</string> | |
</dict> | |
</dict> | |
<key>end</key> | |
<string>^(?!\1 |\n)|^(?=%|-)</string> | |
<key>name</key> | |
<string>text.haml</string> | |
<key>patterns</key> | |
<array> | |
<dict> | |
<key>include</key> | |
<string>source.sass</string> | |
</dict> | |
</array> | |
</dict> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment