Created
September 3, 2013 14:44
-
-
Save stew/6424904 to your computer and use it in GitHub Desktop.
This file contains 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
; scala-mode2 found here: https://github.com/hvesalai/scala-mode2 is much better than the scala mode that comes with scalac | |
(add-to-list 'load-path "~/.emacs.d/scala-mode2/") | |
(require 'scala-mode) | |
; http://www.emacswiki.org/emacs/RainbowDelimiters | |
(add-hook 'scala-mode-hook 'rainbow-delimiters-mode) | |
; I get ensime from git: | |
; https://github.com/aemoncannon/ensime | |
; then run `sbt stage` inside the ensime source directory, | |
; then copy the resulting dist directory to ~/.emacs.d/ensime | |
(add-to-list 'load-path "~/.emacs.d/ensime/elisp") | |
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook) | |
; help ensime find documentation urls: | |
(defun make-scalaz-doc-url (type &optional member) | |
(ensime-make-scala-doc-url-helper | |
"https://scalazproject.ci.cloudbees.com/job/nightly/lastStableBuild/artifact/target/scala-2.9.2/unidoc/" type member)) | |
(add-to-list 'ensime-doc-lookup-map '("^scalaz\\." . make-scalaz-doc-url)) | |
(defun make-scalatra-doc-url (type &optional member) | |
(ensime-make-scala-doc-url-helper | |
"http://scalatra.org/2.2/api/" type member)) | |
(add-to-list 'ensime-doc-lookup-map '("^org\\.scalatra\\." . make-scalatra-doc-url)) | |
; if you run ensime a bunch, this can be unfortunetely handy | |
(defun killall-java () | |
(interactive) | |
(shell-command "killall java")) | |
(global-set-key (kbd "C-c C-v K") 'killall-java) | |
; automatically make arrows fancy | |
(defun scala-right-arrow () | |
(interactive) | |
(cond ((looking-back "=") | |
(backward-delete-char 1) (insert "⇒")) | |
((looking-back "-") | |
(backward-delete-char 1) (insert "→")) | |
(t (insert ">")))) | |
(defun scala-left-arrow () | |
(interactive) | |
(if (looking-back "<") | |
(progn (backward-delete-char 1) | |
(insert "←")) | |
(insert "-"))) | |
; this makes C-M-a do a better job of finding the beginning of a definition | |
(defun scala-beginning-of-defun (&optional arg) | |
(re-search-backward "\\(\\(case\\s*\\)?class\\|def\\|object\\|trait\\)" nil t arg)) | |
; this makes C-M-e do a better job of finding the beginning of a definition | |
(defun scala-end-of-defun (&optional arg) | |
(scala-beginning-of-defun) | |
(goto-char (- (search-forward "{") 1)) | |
(forward-sexp)) | |
(add-hook 'scala-mode-hook | |
'(lambda () | |
(local-set-key (kbd "-") 'scala-left-arrow) | |
(local-set-key (kbd ">") 'scala-right-arrow) | |
(set (make-local-variable 'beginning-of-defun-function) 'scala-beginning-of-defun) | |
(set (make-local-variable 'end-of-defun-function) 'scala-end-of-defun) | |
(hs-minor-mode))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment