cc by-sa flurdy

Scala development in Sublime Text using Ensime

Table of contents

  1. Introduction
  2. Install Sublime Text
  3. Install Ensime within SBT
  4. Install Ensime for Sublime
  5. Configure Sublime
  6. Start Ensime
  7. Use Ensime
  8. More plugins
  9. Notes
  10. References
  11. Feedback
Created 2013-07-04. Updated 2016-01-24.

I love Sublime Text, 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.

Install Sublime Text

You probably already have Sublime installed, but if not go to Sublime Text's website and download the appropriate version. Currently version 3 is the valid version even though it is technically still called beta.

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.

Ensime plugins for exists for other editors as well, Atom, Emacs and Vim.

Install Ensime within SBT

This assumes you already have Scala and SBT (or Typesafe's Activator) installed.

Go to the plugin folder of SBT and add the Ensime SBT plugin by appending the Ensime SBT plugin to ~/.sbt/0.13/plugins/plugins.sbt.

mkdir -p ~/.sbt/0.13/plugins;
echo "addSbtPlugin(\"org.ensime\" % \"ensime-sbt\" % \"0.3.3\")" >> ~/.sbt/0.13/plugins/plugins.sbt

For more up-to-date version numbers, check github.com/ensime/ensime-sbt.

Go to your project folder and let Ensime generate its configuration files:

cd ~/Code/myproject;
sbt gen-ensime

Note Ensime requires you project to be using SBT 0.13.5 or later. (check your project's project/build.properties)

Install Ensime for Sublime

For older versions you cloned the sublime-ensime package into Sublime's package folder. And a whole lot more.
(~/Library/Application\ Support/Sublime\ Text\ 3/Packages or ~/.config/sublime-text-3/Packages)

But the current versions are all available via Sublime's package manager. Ensure you have package manager installed. In Sublime open the package manager's install package menu by pressing cmd+shift+p in OSX or ctrl+shift+p in Linux, and look for "Install packges". In its dropdown search for and select Ensime.

Start Ensime

You no longer need to launch external scripts or configure anything, simply open Sublime's command palette (cmd/ctrl+shift+p) and find and run Ensime: Startup

Note this may take a little awhile. Logs are available to debug what is going on. This is usually the point you realise you missed a step or typoed somewhere...

Use Ensime

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.

More plugins

There are a lot of plugins, such as:

Notes

The latest update to the Sublime Ensime plugin's README and website now also explains parts of this setup.

References

feedback

cc by-sa flurdy