Hey! Remember:
- Saving.
- Switching to your browser (or attempting to compile/run).
- Refreshing.
- Finding out you had a syntax error in your source code.
- Switching back to TextMate.
- Fixing the error.
- Saving.
- Switching back to the browser.
- Refreshing?
This bundle lets you skips several of those steps.
- Bash (optionally using Shellcheck)
- CoffeeScript
- CSS
- Erlang (possibly buggy, compiles *.beam file using erlc)
- Haml
- JavaScript
- JSON
- Perl
- PHP
- Python (using PyFlakes)
- Ruby (optionally using Rubocop)
- Sass/Compass (still a bit buggy)
Follow these instructions if you have Git installed:
mkdir -p ~/Library/Application\ Support/TextMate/Bundles/; #just in case you are missing the folder
cd ~/Library/Application\ Support/TextMate/Bundles/;
git clone git://github.com/sxtxixtxcxh/validate-on-save.tmbundle.git "Validate On Save.tmbundle";
osascript -e 'tell app "TextMate" to reload bundles';
Installing via Git will allow you to keep up to date with the Bundles
> Validate On Save
> Update Bundle
menu command.
If you don't have Git and downloaded this from Github (really? you don't have Git?), after you've unzipped or untarred, you'll have to rename the folder from sxtxixtxcxh-validate-on-save.tmbundle-#{HASH}
to Validate On Save.tmbundle
. Double click and TextMate should install it for you.
You can customize how and when VOS (Validate On Save) notifies you. This is done by setting Shell Variables in TextMate (Textmate
> Preferences
> Advanced
> Shell Variables
). All variables starting with VOS_
take values of either "true" or "false".
VOS_VALIDATOR_INFO
: Outputs information about the validator. (defaults to "false")VOS_ONLY_ON_ERROR
: Only displays notifications on syntax error. Useful if you don't want to be told repeatedly that everything is OK. (defaults to "false")VOS_TM_NOTIFY
: Display the validation result in a TextMate tooltip. If you use Growl, you might want to disable this. (defaults to "true")VOS_GROWL
: Use Growl to display the validation result. (defaults to "false")VOS_JUMP_TO_ERROR
: When a error is found, automatically move the cursor to the line causing the problem. (defaults to "false")VOS_TRIM_LINES
: Remove trailing whitespaces from non-empty lines (defaults to "true")VOS_TRIM_DOCUMENT
: Remove trailing whitespaces and new lines from end of document (defaults to "false")VOS_ERL_OUTPUT_TO_TMP
: When validating Erlang, the.erl
file you are working on needs to be compiled to a.beam
file to look for any syntax errors. By default when VOS compiles your file, it outputs the resulting compiled beam file to/tmp
after which it removes it. Set this to false to have the beam file be outout to the same directory as the.erl
file you are working on. (defaults to "false")VOS_CSS_PROFILE
: When to validate css against a specific profile. See CSS Validator sommand settings for a list of valid profiles. (defaults to 2.1)VOS_BASH_SHELLCHECK
: use Shellcheck instead of Bash to check shell scriptsVOS_RUBY_RUBOCOP
: use RuboCop instead of Ruby to check Ruby scripts
These options are used to specify the full path to the executable binaries for the different commands VOS relies upon. With the exception of TM_GROWLNOTIFY
, TM_RUBY
, TM_COFFEESCRIPT
and TM_ERB
, all of these must be specified for their corresponding validator to work.
TM_BASH
TM_COFFEESCRIPT
TM_COMPASS
TM_ERB
TM_ERLC
TM_GROWLNOTIFY
TM_HAML
TM_PERL
TM_PYFLAKES
TM_RUBOCOP
TM_RUBY
/TM_VOS_RUBY
TM_SASS
TM_SHELLCHECK
If TM_COMPASS
is set to "false", validation is done using the standard Sass binary.
TM_VOS_RUBY
takes priority over TM_RUBY
and is useful in the cases that you
want TextMate to use a different Ruby or Ruby wrapper for validation vs. testing as TM_VOS_RUBY
is always run with -w
.
If you haven't already done so, make sure your TextMate PATH
shell variable includes /usr/local/bin
.
If you installed via the recommended method above by running git clone...
, you can easily update the bundle via Bundles
> Validate On Save
> Update Bundle
.
This is a very early release, so it might not work out so well for you. Feel free to let me know at [email protected] or on twitter.
The Compass "validation" actually compiles your SASS files and returns any errors or warnings.
If you are using a standalone Compass project, it depends on being able to find your config.rb
file in either the same directory as your SASS files or in one any of the parent directories.
If you're using Compass with Rails it runs compass --update
on your Rails root directory, as determined by the parent of the app
or public
directory. This means your SASS files must be descendants of one of those directories. Compass, by default, installs into #{RAILS_ROOT}/app/stylesheets/
.
CSS validation is done locally using w3c.org's Jigsaw server. This means it's essentially booting up a java based web server, so it can be relatively slow.
JSON validation is done using jsonlint
, which is installable through the Node Package manager npm
. For installation details, see jsonlint.
Many thanks to jimeh for refusing to accept my messy code.
Thanks to Peter Hillerström for the css profile update.
Validate On Save is released under the MIT License. Included third-party software are limited to their respective licenses.
growlnotify
is Copyright (c) The Growl Project, 2004-2009 - see growl_license.txt.- JavaScript Lint Based on SpiderMonkey, which is licensed under the MPL/GPL/LGPL tri-license
- Jigsaw and CSS Validator are distributed under both the W3C Test Suite License and the W3C 3-clause BSD License. To contribute to a W3C Test Suite, see the policies and contribution forms.