I love Sublime Text 2, and whilst I do use IntelliJ for some of my Scala development, I do find myself using Sublime more and more. And with that it is nice to have proper syntax highlighting and even compilation errors inside Sublime.
Enter Ensime, the ENhanced Scala Interaction Mode for Emacs, except I use it with Sublime. Sprinkle some other helpful plugins and we have a lightweight but powerful development environment.
Note this is an older howo aimed at Sublime Text 2. A newer version of this howto is available, aimed at Sublime Text 3 and a newer Ensime plugin.
Sublime Text 3 is (at the time of writing) just been released in beta mode. Until it matures a little, or rather until 3rd party plugins migrates I will stick to version 2.
You probably already have Sublime installed, but if not go to Sublime Text's website and download the appropriate version.
Install it via your normal OS installation method.
Note: Sublime Text is not open source nor free, whilst you can keep using it for free it will nag you to purchase the full version.
This assumes you already have Scala and SBT installed.
Go to the plugin folder of SBT and add the Ensime plugin:
Open or create ~/.sbt/plugins/plugins.sbt and append addSbtPlugin("org.ensime" % "ensime-sbt-cmd" % "0.1.1").
mkdir -p ~/.sbt/plugins;
echo "addSbtPlugin(\"org.ensime\" % \"ensime-sbt-cmd\" % \"0.1.1\")" >> ~/.sbt/plugins/plugins.sbt
For more up-to-date version numbers, check github.com/aemoncannon/ensime-sbt-cmd.
Go to your project folder and let Ensime generate its configuration files:
cd ~/Code/myproject;
sbt
ensime generate
Go to the packages folder of Sublime:
For OSX:
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
For Linux:
cd ~/.config/sublime-text-2/Packages
And clone the Sublime-Ensime plugin into this folder as Ensime:
git clone https://github.com/sublimescala/sublime-ensime.git Ensime
Next you need to install the server into this Sublime Ensime folder. The sublime scala project has a list of suitable downloads. Assuming you are within "Sublime Text 2/Packages" folder still, extract the latest server with:
tar xzf ~/Downloads/ensime_*;
mv ensime_* Ensime/server
Start Sublime, then start Ensime by either right click and choose Ensime/Maintenance/Startup.
This is usually the point you realise you missed a step or typoed somewhere...
Ensime will now highlight compilation errors.
If you right click a method/variable and right click Ensime/Development/Go to definition, you can navigate your code as an IDE. Keyboard shortcuts make this quicker.
If you use Play! framework, then Guillaume Bort's excellent Sublime package is usefull for syntax and error highlighting, even in templates.
For a scala REPL inside Sublime have a look at github.com/laughedelic/SublimeREPL.
For simple interaction with Git have a look at github.com/kemayo/sublime-text-2-git. I use GitGutter which marks changes in the left margin (and then the excellent SourceTree for Git interactions).
For simple Cucumber and Gherkin highlighting have a look at github.com/npverni/cucumber-sublime2-bundle.