2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- Scala Layer packages File for Spacemacs
|
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
|
|
|
;;
|
|
|
|
;; 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
|
|
|
'(
|
2015-02-20 07:41:28 +00:00
|
|
|
projectile
|
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
|
|
|
|
2015-02-20 07:41:28 +00:00
|
|
|
(defun scala/init-projectile ()
|
|
|
|
(use-package projectile
|
|
|
|
:defer t))
|
|
|
|
|
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-02-20 09:26:13 +00:00
|
|
|
(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))
|
|
|
|
|
|
|
|
(evil-leader/set-key-for-mode 'scala-mode
|
|
|
|
"m/" 'ensime-search
|
|
|
|
"m?" 'ensime-scalex
|
2015-02-14 15:26:20 +00:00
|
|
|
|
|
|
|
"mbc" 'ensime-sbt-do-compile
|
2015-02-18 02:57:08 +00:00
|
|
|
"mbC" 'ensime-sbt-do-clean
|
|
|
|
"mbi" 'ensime-sbt-switch
|
2015-02-14 15:26:20 +00:00
|
|
|
"mbp" 'ensime-sbt-do-package
|
|
|
|
"mbr" 'ensime-sbt-do-run
|
|
|
|
|
2015-02-18 02:57:08 +00:00
|
|
|
"mct" 'ensime-typecheck-current-file
|
|
|
|
"mcT" 'ensime-typecheck-all
|
|
|
|
|
2015-05-19 02:48:44 +00:00
|
|
|
"mdA" 'ensime-db-attach
|
2015-02-14 15:26:20 +00:00
|
|
|
"mdb" 'ensime-db-set-break
|
2015-02-18 02:57:08 +00:00
|
|
|
"mdB" 'ensime-db-clear-break
|
|
|
|
"mdC" 'ensime-db-clear-all-breaks
|
2015-02-14 15:26:20 +00:00
|
|
|
"mdc" 'ensime-db-continue
|
|
|
|
"mdd" 'ensime-db-start
|
|
|
|
"mdi" 'ensime-db-inspect-value-at-point
|
|
|
|
"mdl" 'ensime-db-list-locals
|
|
|
|
"mdn" 'ensime-db-next
|
|
|
|
"mdo" 'ensime-db-step-out
|
|
|
|
"mdq" 'ensime-db-quit
|
|
|
|
"mdr" 'ensime-db-run
|
|
|
|
"mds" 'ensime-db-step
|
|
|
|
"mdt" 'ensime-db-backtrace
|
2015-02-18 02:57:08 +00:00
|
|
|
|
|
|
|
"mee" 'ensime-print-errors-at-point
|
|
|
|
"mel" 'ensime-show-all-errors-and-warnings
|
|
|
|
"mes" 'ensime-stacktrace-switch
|
2015-02-20 07:41:28 +00:00
|
|
|
|
2015-02-18 02:57:08 +00:00
|
|
|
"mgg" 'ensime-edit-definition
|
|
|
|
"mgi" 'ensime-goto-impl
|
|
|
|
"mgt" 'ensime-goto-test
|
|
|
|
|
|
|
|
"mhh" 'ensime-show-doc-for-symbol-at-point
|
|
|
|
"mhu" 'ensime-show-uses-of-symbol-at-point
|
|
|
|
"mht" 'ensime-print-type-at-point
|
|
|
|
|
|
|
|
"mii" 'ensime-inspect-type-at-point
|
|
|
|
"miI" 'ensime-inspect-type-at-point-other-frame
|
|
|
|
"mip" 'ensime-inspect-project-package
|
|
|
|
|
|
|
|
"mnF" 'ensime-reload-open-files
|
|
|
|
"mns" 'ensime
|
|
|
|
"mnS" 'ensime-gen-and-restart
|
|
|
|
|
|
|
|
"mrd" 'ensime-refactor-inline-local
|
|
|
|
"mrD" 'ensime-undo-peek
|
|
|
|
"mrf" 'ensime-format-source
|
|
|
|
"mri" 'ensime-refactor-organize-imports
|
|
|
|
"mrm" 'ensime-refactor-extract-method
|
|
|
|
"mrr" 'ensime-refactor-rename
|
|
|
|
"mrt" 'ensime-import-type-at-point
|
|
|
|
"mrv" 'ensime-refactor-extract-local
|
|
|
|
|
|
|
|
"mta" 'ensime-sbt-do-test
|
|
|
|
"mtr" 'ensime-sbt-do-test-quick
|
|
|
|
"mtt" 'ensime-sbt-do-test-only
|
|
|
|
|
2015-02-18 03:05:42 +00:00
|
|
|
"msa" 'ensime-inf-load-file
|
2015-02-18 02:57:08 +00:00
|
|
|
"msb" 'ensime-inf-eval-buffer
|
|
|
|
"msB" 'ensime-inf-eval-buffer-switch
|
|
|
|
"msi" 'ensime-inf-switch
|
|
|
|
"msr" 'ensime-inf-eval-region
|
|
|
|
"msR" 'ensime-inf-eval-region-switch
|
|
|
|
|
|
|
|
"mz" '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.
|
|
|
|
(eval-after-load 'flycheck
|
|
|
|
'(progn
|
2015-01-03 02:31:13 +00:00
|
|
|
(defun scala/disable-flycheck () (flycheck-mode -1))
|
|
|
|
(add-hook 'ensime-mode-hook 'scala/disable-flycheck))))))
|
2014-12-29 21:00:07 +00:00
|
|
|
|
2015-04-03 21:35:33 +00:00
|
|
|
(defun scala/init-noflet ())
|
|
|
|
|
|
|
|
(defun scala/init-sbt-mode ())
|
|
|
|
|
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
|
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'
|
|
|
|
(custom-set-variables
|
2014-12-30 21:52:17 +00:00
|
|
|
'(scala-indent:align-forms t)
|
|
|
|
'(scala-indent:align-parameters t)
|
|
|
|
'(scala-indent:default-run-on-strategy scala-indent:operator-strategy))
|
2014-12-29 21:00:07 +00:00
|
|
|
|
2015-01-23 03:28:35 +00:00
|
|
|
(require 'noflet)
|
|
|
|
|
2014-12-29 21:00:07 +00:00
|
|
|
(defadvice scala-indent:indent-code-line (around retain-trailing-ws activate)
|
|
|
|
"Keep trailing-whitespace when indenting."
|
|
|
|
(noflet ((scala-lib:delete-trailing-whitespace ()))
|
|
|
|
ad-do-it)))))
|