2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- Scala Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq scala-packages
|
2014-12-14 04:29:23 +00:00
|
|
|
'(
|
|
|
|
ensime
|
2015-04-03 02:43:21 +00:00
|
|
|
noflet
|
2014-12-14 04:29:23 +00:00
|
|
|
sbt-mode
|
|
|
|
scala-mode2
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2014-12-14 04:29:23 +00:00
|
|
|
|
2014-12-30 21:51:41 +00:00
|
|
|
(defun scala/init-ensime ()
|
2014-12-14 04:29:23 +00:00
|
|
|
(use-package ensime
|
2014-12-29 20:47:56 +00:00
|
|
|
:commands (ensime-mode)
|
|
|
|
:init
|
2015-01-03 02:29:02 +00:00
|
|
|
(progn
|
2015-11-23 19:09:57 +00:00
|
|
|
(when scala-enable-eldoc
|
|
|
|
(add-hook 'ensime-mode-hook 'scala/enable-eldoc))
|
2015-01-03 02:29:02 +00:00
|
|
|
(add-hook 'scala-mode-hook 'scala/configure-flyspell)
|
2015-02-20 07:41:28 +00:00
|
|
|
(add-hook 'scala-mode-hook 'scala/configure-ensime)
|
|
|
|
(add-hook 'scala-mode-hook 'scala/maybe-start-ensime))
|
2014-12-29 20:40:56 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-06-01 21:15:12 +00:00
|
|
|
(setq user-emacs-ensime-directory ".cache/ensime")
|
|
|
|
|
2015-02-20 07:17:42 +00:00
|
|
|
(evil-define-key 'insert ensime-mode-map
|
|
|
|
(kbd ".") 'scala/completing-dot
|
|
|
|
(kbd "M-.") 'ensime-edit-definition
|
|
|
|
(kbd "M-,") 'ensime-pop-find-definition-stack)
|
|
|
|
|
|
|
|
(evil-define-key 'normal ensime-mode-map
|
|
|
|
(kbd "M-.") 'ensime-edit-definition
|
|
|
|
(kbd "M-,") 'ensime-pop-find-definition-stack)
|
2015-01-03 02:30:17 +00:00
|
|
|
|
2014-12-29 20:40:56 +00:00
|
|
|
(evil-define-key 'normal ensime-popup-buffer-map
|
|
|
|
(kbd "q") 'ensime-popup-buffer-quit-function)
|
|
|
|
|
2015-02-20 07:17:42 +00:00
|
|
|
(evil-define-key 'normal ensime-inspector-mode-map
|
|
|
|
(kbd "q") 'ensime-popup-buffer-quit-function)
|
|
|
|
|
2014-12-29 20:40:56 +00:00
|
|
|
(evil-define-key 'normal ensime-refactor-info-map
|
|
|
|
(kbd "q") 'spacemacs/ensime-refactor-cancel
|
|
|
|
(kbd "c") 'spacemacs/ensime-refactor-accept
|
|
|
|
(kbd "RET") 'spacemacs/ensime-refactor-accept)
|
|
|
|
|
|
|
|
(evil-define-key 'normal ensime-compile-result-map
|
|
|
|
(kbd "g") 'ensime-show-all-errors-and-warnings
|
|
|
|
(kbd "TAB") 'forward-button
|
|
|
|
(kbd "<backtab>") 'backward-button
|
|
|
|
(kbd "M-n") 'forward-button
|
2014-12-30 22:19:43 +00:00
|
|
|
(kbd "M-p") 'backward-button
|
|
|
|
(kbd "n") 'forward-button
|
|
|
|
(kbd "N") 'backward-button)
|
2014-12-29 20:59:27 +00:00
|
|
|
|
2015-02-18 02:57:08 +00:00
|
|
|
(defun ensime-gen-and-restart()
|
|
|
|
"Regenerate `.ensime' file and restart the ensime server."
|
2015-02-14 15:26:20 +00:00
|
|
|
(interactive)
|
|
|
|
(progn
|
|
|
|
(sbt-command "gen-ensime")
|
|
|
|
(ensime-shutdown)
|
2015-02-18 02:57:08 +00:00
|
|
|
(ensime)))
|
2015-02-14 15:26:20 +00:00
|
|
|
|
2015-02-18 02:57:08 +00:00
|
|
|
(defun ensime-inf-eval-buffer-switch ()
|
|
|
|
"Send buffer content to shell and switch to it in insert mode."
|
|
|
|
(interactive)
|
|
|
|
(ensime-inf-eval-buffer)
|
|
|
|
(ensime-inf-switch)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
|
|
|
(defun ensime-inf-eval-region-switch (start end)
|
|
|
|
"Send region content to shell and switch to it in insert mode."
|
|
|
|
(interactive "r")
|
|
|
|
(ensime-inf-switch)
|
|
|
|
(ensime-inf-eval-region start end)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
2015-10-20 07:59:53 +00:00
|
|
|
(dolist (prefix '(("mb" . "scala/build")
|
|
|
|
("mc" . "scala/check")
|
|
|
|
("md" . "scala/debug")
|
|
|
|
("me" . "scala/errors")
|
|
|
|
("mg" . "scala/goto")
|
|
|
|
("mh" . "scala/docs")
|
|
|
|
("mi" . "scala/inspect")
|
|
|
|
("mn" . "scala/ensime")
|
|
|
|
("mr" . "scala/refactor")
|
|
|
|
("mt" . "scala/test")
|
|
|
|
("ms" . "scala/repl")))
|
|
|
|
(spacemacs/declare-prefix-for-mode 'scala-mode (car prefix) (cdr prefix)))
|
|
|
|
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'scala-mode
|
|
|
|
"/" 'ensime-search
|
|
|
|
|
|
|
|
"bc" 'ensime-sbt-do-compile
|
|
|
|
"bC" 'ensime-sbt-do-clean
|
|
|
|
"bi" 'ensime-sbt-switch
|
|
|
|
"bp" 'ensime-sbt-do-package
|
|
|
|
"br" 'ensime-sbt-do-run
|
|
|
|
|
|
|
|
"ct" 'ensime-typecheck-current-file
|
|
|
|
"cT" 'ensime-typecheck-all
|
|
|
|
|
|
|
|
"dA" 'ensime-db-attach
|
|
|
|
"db" 'ensime-db-set-break
|
|
|
|
"dB" 'ensime-db-clear-break
|
|
|
|
"dC" 'ensime-db-clear-all-breaks
|
|
|
|
"dc" 'ensime-db-continue
|
|
|
|
"dd" 'ensime-db-start
|
|
|
|
"di" 'ensime-db-inspect-value-at-point
|
|
|
|
"dl" 'ensime-db-list-locals
|
|
|
|
"dn" 'ensime-db-next
|
|
|
|
"do" 'ensime-db-step-out
|
|
|
|
"dq" 'ensime-db-quit
|
|
|
|
"dr" 'ensime-db-run
|
|
|
|
"ds" 'ensime-db-step
|
|
|
|
"dt" 'ensime-db-backtrace
|
|
|
|
|
|
|
|
"ee" 'ensime-print-errors-at-point
|
|
|
|
"el" 'ensime-show-all-errors-and-warnings
|
|
|
|
"es" 'ensime-stacktrace-switch
|
|
|
|
|
|
|
|
"gg" 'ensime-edit-definition
|
|
|
|
"gp" 'ensime-pop-find-definition-stack
|
|
|
|
"gi" 'ensime-goto-impl
|
|
|
|
"gt" 'ensime-goto-test
|
|
|
|
|
|
|
|
"hh" 'ensime-show-doc-for-symbol-at-point
|
|
|
|
"hu" 'ensime-show-uses-of-symbol-at-point
|
|
|
|
"ht" 'ensime-print-type-at-point
|
|
|
|
|
|
|
|
"ii" 'ensime-inspect-type-at-point
|
|
|
|
"iI" 'ensime-inspect-type-at-point-other-frame
|
|
|
|
"ip" 'ensime-inspect-project-package
|
|
|
|
|
|
|
|
"nF" 'ensime-reload-open-files
|
|
|
|
"ns" 'ensime
|
|
|
|
"nS" 'ensime-gen-and-restart
|
|
|
|
|
|
|
|
"rd" 'ensime-refactor-inline-local
|
|
|
|
"rD" 'ensime-undo-peek
|
|
|
|
"rf" 'ensime-format-source
|
|
|
|
"ri" 'ensime-refactor-organize-imports
|
|
|
|
"rm" 'ensime-refactor-extract-method
|
|
|
|
"rr" 'ensime-refactor-rename
|
|
|
|
"rt" 'ensime-import-type-at-point
|
|
|
|
"rv" 'ensime-refactor-extract-local
|
|
|
|
|
|
|
|
"ta" 'ensime-sbt-do-test-dwim
|
|
|
|
"tr" 'ensime-sbt-do-test-quick-dwim
|
|
|
|
"tt" 'ensime-sbt-do-test-only-dwim
|
|
|
|
|
|
|
|
"sa" 'ensime-inf-load-file
|
|
|
|
"sb" 'ensime-inf-eval-buffer
|
|
|
|
"sB" 'ensime-inf-eval-buffer-switch
|
|
|
|
"si" 'ensime-inf-switch
|
|
|
|
"sr" 'ensime-inf-eval-region
|
|
|
|
"sR" 'ensime-inf-eval-region-switch
|
|
|
|
|
|
|
|
"z" 'ensime-expand-selection-command
|
2015-02-14 15:26:20 +00:00
|
|
|
)
|
|
|
|
|
2014-12-29 20:59:27 +00:00
|
|
|
;; Don't use scala checker if ensime mode is active, since it provides
|
|
|
|
;; better error checking.
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'flycheck
|
2015-10-14 12:35:05 +00:00
|
|
|
(defun scala/disable-flycheck-scala ()
|
|
|
|
(push 'scala flycheck-disabled-checkers))
|
|
|
|
|
2015-11-02 10:11:43 +00:00
|
|
|
(add-hook 'ensime-mode-hook 'scala/disable-flycheck-scala))
|
|
|
|
|
|
|
|
;; Enable Expand Region integration from Ensime. Ignore load errors to
|
|
|
|
;; handle older Ensime versions gracefully.
|
|
|
|
(when (configuration-layer/package-usedp 'expand-region)
|
|
|
|
(require 'ensime-expand-region nil 'noerror)))))
|
2014-12-29 21:00:07 +00:00
|
|
|
|
2015-12-30 09:24:48 +00:00
|
|
|
(defun scala/init-noflet ()
|
|
|
|
(use-package noflet))
|
2015-04-03 21:35:33 +00:00
|
|
|
|
2015-10-13 10:39:37 +00:00
|
|
|
(defun scala/init-sbt-mode ()
|
|
|
|
(use-package sbt-mode
|
|
|
|
:config
|
|
|
|
(progn
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'scala-mode
|
|
|
|
"bb" 'sbt-command))))
|
2015-04-03 21:35:33 +00:00
|
|
|
|
2014-12-30 21:51:41 +00:00
|
|
|
(defun scala/init-scala-mode2 ()
|
2014-12-29 21:00:07 +00:00
|
|
|
(use-package scala-mode2
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(dolist (ext '(".cfe" ".cfs" ".si" ".gen" ".lock"))
|
|
|
|
(add-to-list 'completion-ignored-extensions ext))
|
|
|
|
:config
|
|
|
|
(progn
|
2015-12-30 15:54:28 +00:00
|
|
|
;; Automatically insert asterisk in a comment when enabled
|
|
|
|
(defun scala/newline-and-indent-with-asterisk ()
|
|
|
|
(interactive)
|
|
|
|
(newline-and-indent)
|
2016-01-04 09:46:22 +00:00
|
|
|
(when scala-auto-insert-asterisk-in-comments
|
2015-12-30 15:54:28 +00:00
|
|
|
(scala-indent:insert-asterisk-on-multiline-comment)))
|
|
|
|
|
|
|
|
(evil-define-key 'insert scala-mode-map
|
|
|
|
(kbd "RET") 'scala/newline-and-indent-with-asterisk)
|
|
|
|
|
2014-12-30 21:53:03 +00:00
|
|
|
(evil-define-key 'normal scala-mode-map "J" 'spacemacs/scala-join-line)
|
|
|
|
|
2014-12-29 21:00:07 +00:00
|
|
|
;; Compatibility with `aggressive-indent'
|
2015-08-08 20:32:36 +00:00
|
|
|
(setq scala-indent:align-forms t
|
|
|
|
scala-indent:align-parameters t
|
2015-12-30 09:24:48 +00:00
|
|
|
scala-indent:default-run-on-strategy scala-indent:operator-strategy))))
|