The result was very cool, but syntax highlighting was missing.
After playing around a bit I found out how to enable syntax highlighting for Groovy in Quick Look.
Here is how it works:
Unfortunately the plugin does not support Groovy out of the box, but we will change that. After installing the plugin you should have the package
QLColorCode.qlgenerator
in your ~/Library/QuickLook
.
QLColorCode.qlgenerator
package. Either by right-clicking in Finder and choosing "Show Package Contents" or by navigating into the directory in a shell.
Resources/colorize.sh
.
Extend the case-statement in the middle of the script the following way:
... case $target in *.graffle ) # some omnigraffle files are XML and get passed to us. Ignore them. exit 1 ;; *.plist ) lang=xml reader=(/usr/bin/plutil -convert xml1 -o - $target) ;; *.h ) if grep -q "@interface" $target &> /dev/null; then lang=objc else lang=h fi ;; *.m ) # look for a matlab-style comment in the first 10 lines, otherwise # assume objective-c. If you never use matlab or never use objc, # you might want to hardwire this one way or the other if head -n 10 $target | grep -q "^ *%" &> /dev/null; then lang=m else lang=objc fi ;; *.groovy ) lang=java ;; * ) lang=${target##*.} ;; esac ...
This tells Highlight to treat Groovy files as Java source code.
Info.plist
inside the QLColorCode.qlgenerator package.
Add the follwing snippet at the end of
Info.plist
(just before the ending </array> </dict> </plist>)
UTTypeConformsTo public.source-code UTTypeDescription Groovy Source Code UTTypeIdentifier org.codehaus.groovy-source UTTypeTagSpecification public.filename-extension groovy
QLColorCode.qlgenerator
) to the desktop then back to its installed location should do the trick.
This should be it! The result is Quick Look for Groovy with syntax highlighting:
The syntax highlighting is still not perfect, since it is Java highlighting... but it is much better than no highlighting.
Thanks for sharing very useful information.
ReplyDeleteUpdate for Snow Leopard:
ReplyDeleteIn order to get QLColorCode running on Snow Leopard, follow this adivce:
Important information on using QLColorCode with Xcode v3.2 and later
... it worked for me :-)