Friday 10 June 2011

Better Scala syntax highlighting in Sublime Text 2

(NOTE: this post is now redundant, Scala syntax highlighting in Sublime Text 2 is now dramatically better as of Build 2065, released on June 15th 2011)

At the recommendation of @roblally I decided to give Sublime Text 2 a spin, as I was starting to grow impatient with poor tooling for Scala development. I've been using IntelliJ 1.5 CE with the Scala Plugin and the SBT plugin for a week or so, but I've been getting really frustrated with how slow the whole setup has been and the inaccurate error reporting. So, perhaps it's time to go all caveman and go back to using just a text editor and SBT in a command line. I often use jEdit for simple editing of LaTeX and other such documents, but Rob believed Sublime would be worth a spin for coding oriented development. So, here we are.

So, I've been using it for all of about 15 minutes. The first thing that immediately popped out at me was that the syntax highlighting for Scala was incorrect - often in my Lift code where there are a number of objects declared within Mapper classes the syntax highlighting would pick out the object keyword on the first line, but not on subsequent lines. Minor point, obviously, but I like this kind of basic stuff to work or I don't see the point in having it at all. So, turns out the syntax highlighting in Sublime Text uses TextMate definition files, so with a quick Google I was able to find a github repo by mariussoutier that provides a better .tmLanguage definition file for Scala than that which ships with Sublime Text just now. The syntax file is here and you can just copy-paste the contents of that over the top of what exists in Sublime Text, and it seems to just work.