Created
May 4, 2012 18:56
-
-
Save conikeec/2596994 to your computer and use it in GitHub Desktop.
Scala Ensime Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Recently I’ve become disillusioned with the state of the JVM IDE: I haven’t touched Eclipse in anger in 3 years, and have no intention to do so anytime soon. IntelliJ on the other hand has served me decently, but suffers from too many odd bugs when dealing with Scala code to not be a minor nuisance in my workflow. Not only that, “modern” IDE’s are massive workspace hogs: try working with IntelliJ without at least a 1920x1200 resolution screen. | |
For these reasons, I’ve decided to try using Emacs for development for a month or so to see how it compares, and so far, so good. | |
Setting Up Emacs for Scala Development | |
Setting up Emacs for Scala development is fairly easy, just do the following: | |
Create a folder called ~/.emacs.d/scala-mode (in your home folder). You might already have an .emacs.d folder there, if not, create it. | |
Copy all contents from $SCALA_HOME/misc/scala-tool-support/emacs into ~/.emacs.d/scala-mode. I found that this folder is missing in the latest Scala 2.9.2 distribution, but you can get it from the 2.9.1 distribution. Also I found the current equivalent content in GitHub has some issues, so until a new version is released, prefer the 2.9.1 distribution for Emacs tools support. | |
Create a folder called ~/.emacs.d/ensime. | |
Download ensime (https://github.com/aemoncannon/ensime/downloads) , and add the contents of the zip files folder into ~/.emacs.d/ensime. | |
Add the following contents into a file called ~/.emacs.d/init.el: https://gist.github.com/2499183 | |
You should now have ensime and Scala-mode installed in Emacs. Now it’s time to set up SBT! | |
Setting up SBT | |
To setup sbt, all you need to do is create a file called ~/.sbt/plugins/build.sbt with the following content (or add it if you already have it): https://gist.github.com/2499204 | |
This sets up the sbt ensime plugin (https://github.com/aemoncannon/ensime-sbt-cmd) as a global sbt plugin for you that is available for all projects. | |
Using Emacs with SBT and Scala | |
This should conclude the setup of your environment. For existing SBT projects, it may be a good idea to clean out any target and project/target folders, as I found this interferes with the ensime sbt plugin sometimes (not making it available in sbt). | |
To generate a .ensime file that Emacs will use to use the same classpath as your SBT project, simply start your SBT project and enter “ensime generate” into the SBT console. | |
Once you have done this, start Emacs from the folder of your project, run M-x ensime to start the ensime project and off you go! | |
When running Ensime and Scala-mode, Emacs will support code completion, compilation, organising imports, refactorings like renaming, and much more, for complete details, please refer to the Ensime documentation (http://aemon.com/file_dump/ensime_manual.html) | |
If you want a little more, like class templates and the like, you may want to check out Yasnippet (https://github.com/capitaomorte/yasnippet) as well (I have not yet had time to do so) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment