Skip to content

Instantly share code, notes, and snippets.

@edgar
Created October 17, 2011 01:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgar/1291750 to your computer and use it in GitHub Desktop.
Save edgar/1291750 to your computer and use it in GitHub Desktop.
SublimeText2 - Check ruby syntax after save file
# Edit file: /path/to/SublimeText2/Packages/Ruby/Ruby.sublime-build
{
"cmd": ["/home/edgar/.rvm/rubies/ruby-1.9.2-p290/bin/ruby", "-cw", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
# Copy this to: /path/to/SublimeText2/Packages/User/ruby_check.py
import sublime, sublime_plugin
class rubyCheck(sublime_plugin.EventListener):
def on_post_save(self, view):
if view.file_name()[-3:] == '.rb':
view.window().run_command("build")
@betacar
Copy link

betacar commented Oct 25, 2011

It returns a "No Build System" message after every save process. I'm using ruby 1.9.2p180.

@edgar
Copy link
Author

edgar commented Oct 25, 2011

I tested on mac and works nice. You should edit the existent Ruby.sublime-build and change the ruby for the rvm path, in my case is:
/Users/edgar/.rvm/rubies/ruby-1.9.2-p290/bin/ruby

these files in mac are in Library/Application Support/Sublime Text 2/Packages

@betacar
Copy link

betacar commented Oct 26, 2011

It was a missing comma after the "-cw" flag. It works beatiful now.

Thank's!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment