"Hmmm. I need to iterate over each line in a file. How exactly do I do that in Groovy?"
Goes to TextMate menu...
Bundles --> Groovy --> Iteration --> Files & Streams --> eachLine
tab, and TextMate inserts the same code snippet we'd get from the menu.
If you're ready to give it a shot, just follow the pleasantly-simple installation process, and you'll be good to go.
- Download and untar the tarball.
- Copy the bundle files (Groovy.tmbundle and Grails.tmbundle) to ~/Library/Application Support/TextMate/Bundles
- Fire up TextMate and start groovin'!
$ ls -l ~/Library/Application\ Support/TextMate/Bundles/ total 0 drwxr-xr-x 5 jason jason 170 Nov 1 17:33 Grails.tmbundle drwxr-xr-x 6 jason jason 204 Nov 1 17:33 Groovy.tmbundle
For more examples of what you'll get from these bundles, be sure to check out the initial release notes.
And, there's still more to come. Graeme points out that these bundles are a work in progress. In addition to more code snippets, future releases will likely provide the ability to execute a Groovy unit test directly from within TextMate, execute a Groovy script inside TextMate, etc.
If you have a chance to try it out, shoot a quick note to the Groovy mailing list with your thoughts (or post a comment here, and I'll be happy to pass it along).
Work in progress, indeed! Graeme has just added the ability to run Groovy scripts and Groovy classes from within TextMate.
To take advantage of these new features, first make sure you have Groovy installed and that your GROOVY_HOME variable is set. Then, just grab the current version of the bundle, install it, and you're ready to rock.
Once you've installed the latest bundle, open any Groovy file in TextMate, and hit Command + R to run the file in your editor.
Presenting...the gratuitous Hello World example...
Or, if you just want to execute the currently selected text, hit Command + Option + R to run just the selection.
Stay tuned for more updates as they come in.
I modified the bundle links above to point to the locally hosted copy of the bundles, until such time that these bundles make their way to the official TextMate repository. Thanks, Martin, for this suggestion.
The bundles still have yet to make their way to the official TextMate repository, but the Groovy site is now hosting a page on TextMate integration.
At long last, the bundles have found a new home at the official TextMate repository. Not only have they found a new home, but you'll also find some nice new features in the latest revision of the bundles. So, if you previously fetched the bundles from anywhere other than the official TextMate repository, you'll likely want to upgrade to the latest version.