Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created April 20, 2013 00:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/5424179 to your computer and use it in GitHub Desktop.
Save sritchie/5424179 to your computer and use it in GitHub Desktop.
The getting started with ensime post!
// Add this file to ~/.sbt/plugins/plugins.sbt.
//
// Once this is ready, make sure you have sbt 0.12 ("brew install sbt" should do it),
// then try running
//
// sbt "ensime generate"
//
// in bijection's root directory. ("git clone git@github.com:twitter/bijection.git")
resolvers += "Scala-Tools Maven2 Snapshots Repository" at "http://scala-tools.org/repo-snapshots"
addSbtPlugin("org.ensime" % "ensime-sbt-cmd" % "0.1.1")
;; Make sure your package archives contain "melpa"
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("original" . "http://tromey.com/elpa/")
("org" . "http://orgmode.org/elpa/")
("marmalade" . "http://marmalade-repo.org/packages/")
("elpa" . "http://tromey.com/elpa/")
("melpa" . "http://melpa.milkbox.net/packages/")))
;; M-x package-list-packages
;; install scala-mode2
;; Download the latest ensime (https://www.dropbox.com/sh/ryd981hq08swyqr/V9o9rDvxkS/ENSIME%20Releases)
;; and move it over to ~/.emacs.d/ensime
;; Add the elisp directory your load-path:
(add-to-list 'load-path (concat dotfiles-dir "ensime/elisp"))
;; Now! some hooks to get things working:
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
(define-key ensime-mode-map (kbd "C-c C-b") 'ensime-inf-eval-buffer)
(define-key ensime-mode-map (kbd "C-c C-l") 'ensime-inf-load-file)
(define-key ensime-mode-map (kbd "C-c C-r") 'ensime-inf-eval-region)
(add-hook 'scala-mode-hook
'(lambda ()
;; Alternatively, bind the 'newline-and-indent' command and
;; 'scala-indent:insert-asterisk-on-multiline-comment' to RET in
;; order to get indentation and asterisk-insertion within multi-line
;; comments.
(local-set-key (kbd "RET")
'(lambda ()
(interactive)
(newline-and-indent)
(scala-indent:insert-asterisk-on-multiline-comment)))
;; Bind the 'join-line' command to C-M-j. This command is normally
;; bound to M-^ which is hard to access, especially on some European
;; keyboards. The 'join-line' command has the effect or joining the
;; current line with the previous while fixing whitespace at the
;; joint.
(local-set-key (kbd "C-M-j") 'join-line)
;; Bind the backtab (shift tab) to
;; 'scala-indent:indent-with-reluctant-strategy command. This is usefull
;; when using the 'eager' mode by default and you want to "outdent" a
;; code line as a new statement.
(local-set-key (kbd "<backtab>") 'scala-indent:indent-with-reluctant-strategy)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment