Last Updated: September 09, 2019
· jilen

My Emacs Scala Development Environment

Scala related Features

  • Combines scala-mode and sbt-mode
  • Fast editing, without ensime
  • Compile on save
  • On the fly syntax check using flycheck(only check syntax errors, not typecheck).
  • sbt-mode included with a custom command play-start for Play!Framework projects
  • Add an command C-c C-t to run a Specification of specs2 or scalatest
  • In buffer text based completion with company-mode (text based, company won't understand Scala at all)

General Features

  • Based on prelude
  • With a lot of base16 themes bundled
  • Poor written lisp, I haven't learn lisp seriously.


  • clone the repo git clone
  • backup your own .emacs.d config directory
  • mv the cloned repo as .emacs.d
  • start emacs

That's it.


;;; prelude-scala-sbt.el --- Scala2 and sbt mode

;;; Commentary:
;;; Code:
(prelude-require-package 'sbt-mode)
(require 'prelude-scala)
(require 'sbt-mode)
(defun play-start ()
  "Start Play console."
  (let ((sbt:program-name "play")) ; do a 'let' binding for the variable
(setq scala-indent:use-javadoc-style t)

(defun test-only ()
  "Run test with current file."
  (sbt-command (concat "testOnly " (find-spec-name))))

(defun find-spec-name ()
  "Find spec name of current buffer."
  (concat "*." (file-name-sans-extension (file-name-nondirectory (buffer-name)))))

(defun compile-sbt-project ()
  "Compile the sbt project."
  (sbt-command "test:compile")

(add-hook 'scala-mode-hook
          (lambda ()
            (add-hook 'after-save-hook 'compile-sbt-project)))

(provide 'prelude-scala-sbt)
;;; prelude-scala-sbt.el ends here