[scala] remove long-deprecated Ensime integration

According to its website, the Ensime project has been shut down since 2019. We
have been supporting both Ensime and Metals for [a year and a
half](https://github.com/syl20bnr/spacemacs/pull/12234#issuecomment-524916394).
Ensime's GitHub repositories, including its Emacs integration, are archived.
Meanwhile, Metals has been developed actively, regularly releasing new versions.
It has stabilized significantly, and supports an increasingly full set of
features. Scala 3 is just around the corner, and the community is poised to make
the transition smoothly and relatively quickly. Metals supports it already,
whereas of course Ensime does not and never will. In fact, Scala 2 has had
several import minor versions released since Ensime died. Now that it's 2021,
it's time to cut the baggage we are carrying around for Ensime.
This commit is contained in:
Keith Pinson 2021-01-11 11:14:01 -05:00 committed by Maximilian Wolff
parent fc20d1b4c1
commit a973da57ee
8 changed files with 29 additions and 540 deletions

View File

@ -3290,6 +3290,7 @@ files (thanks to Daniel Nicolai)
- ~SPC c s d~ Copy rpms to the phone
- ~SPC c s i~ Install rpms into target
**** Scala
- Remove long-deprecated Ensime support (thanks to Keith Pinson)
- Provide an easy way to configure SBT to use a small buffer at the bottom of
the frame by setting =scala-sbt-window-position= to =bottom= (thanks to Keith
Pinson)

View File

@ -2,7 +2,7 @@
#+TAGS: general|layer|multi-paradigm|programming
[[file:img/scala.png]] with [[file:img/ensime.png]]
[[file:img/scala.png]] with [[file:img/scalameta.png]]
* Table of Contents :TOC_5_gh:noexport:
- [[#description][Description]]
@ -10,53 +10,28 @@
- [[#layer-installation][Layer Installation]]
- [[#backends][Backends]]
- [[#metals][Metals]]
- [[#ensime-deprecated][Ensime (deprecated)]]
- [[#installation-when-using-sbt][Installation when using SBT]]
- [[#installation-when-using-gradle][Installation when using Gradle]]
- [[#configuration][Configuration]]
- [[#usage][Usage]]
- [[#scalastyle][Scalastyle]]
- [[#use-java-doc-style][Use Java doc-style]]
- [[#enable-debug-adapter-protocol-dap][Enable Debug Adapter Protocol (DAP)]]
- [[#automatically-show-the-type-of-the-symbol-under-the-cursor][Automatically show the type of the symbol under the cursor]]
- [[#automatically-insert-asterisk-in-multiline-comments][Automatically insert asterisk in multiline comments]]
- [[#deprecated-automatic-replacement-of-arrows-with-unicode-ones][Deprecated: Automatic replacement of arrows with Unicode ones]]
- [[#enable-gtags-as-a-fallback-navigation-utility][Enable GTags as a fallback navigation utility]]
- [[#auto-start][Auto-start]]
- [[#key-bindings][Key bindings]]
- [[#ensime][Ensime]]
- [[#search][Search]]
- [[#ensime-search-mode][Ensime Search Mode]]
- [[#sbt][sbt]]
- [[#typecheck][Typecheck]]
- [[#debug][Debug]]
- [[#errors][Errors]]
- [[#goto][Goto]]
- [[#print-and-yank-types][Print and yank types]]
- [[#documentation-inspect][Documentation, Inspect]]
- [[#server][Server]]
- [[#refactoring][Refactoring]]
- [[#tests][Tests]]
- [[#repl][REPL]]
- [[#sbt][sbt]]
* Description
This layer adds support for the Scala language to Spacemacs.
** Features:
- Syntax highlighting
- Support for language backend. Either using [[https://ensime.github.io/][ENSIME]] or [[https://scalameta.org/metals/][Metals]]
- Debugging support via dap
- Support for language backend using LSP and [[https://scalameta.org/metals/][Metals]]
- Debugging support via =dap=
- Auto-completion
- Treeview support for viewing project structure and triggering compilation
- Syntax-checking
- Refactoring
- Incremental compilation
- Scala Repl
- Style linting
- Eldoc integration
- Optional GGTags search
- Test execution directly from Emacs
- Automatic replacement of ASCII arrows with unicode ones
* Layer Installation
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
@ -67,28 +42,20 @@ file.
=scala-sbt-window-position= layer variable to =bottom=.
* Backends
The currently supported language backends are:
- scala-metals
- scala-ensime (deprecated)
To set your choice of backend, configure the layer variable =scala-backend=.
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((scala :variables scala-backend 'scala-metals))) ;or 'scala-ensime
#+END_SRC
The only currently supported language backend is =scala-metals=. Support for
Ensime has been dropped as that project has been dead for some time.
** Metals
Currently, you must manually install the metals server. It is possible to do so
Currently, you must manually install the Metals server. It is possible to do so
via coursier; the latest version can be built using the following commands,
where =0.7.6= can be replaced with the current version of [[https://github.com/scalameta/metals/][Metals]]:
where =0.9.8= can be replaced with the current version of [[https://scalameta.org/metals/docs/editors/emacs.html][Metals]]:
#+BEGIN_SRC bash
./coursier bootstrap \
--java-opt -Xss4m \
--java-opt -Xms100m \
--java-opt -Dmetals.client=emacs \
org.scalameta:metals_2.12:0.7.6 \
org.scalameta:metals_2.12:0.9.8 \
-r bintray:scalacenter/releases \
-r sonatype:snapshots \
-o /usr/local/bin/metals-emacs -f
@ -97,54 +64,6 @@ where =0.7.6= can be replaced with the current version of [[https://github.com/s
You will then have the common LSP key bindings; see
[[https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Btools/lsp#key-bindings][LSP#key-bindings]] for more details.
** Ensime (deprecated)
This package is mainly unmaintained today and should only be used as a last resort.
[[https://ensime.github.io/][ENSIME]] provides IDE-like features, such as refactoring, incremental compilation
and project-wide type-checking.
You will also need to modify your =dotspacemacs/user-init= to pull the recommended Ensime
version (Stable):
#+BEGIN_SRC emacs-lisp
(add-to-list 'configuration-layer-elpa-archives '("melpa-stable" . "stable.melpa.org/packages/"))
(add-to-list 'package-pinned-packages '(ensime . "melpa-stable"))
#+END_SRC
ENSIME requires a configuration file at the root of each Scala project. It
provides an SBT plugin, a gradle plugin and others (see [[https://web.archive.org/web/20190427005241/https://ensime.github.io/build_tools/][ensime.org]] for a full
list) to generate these files.
*** Installation when using SBT
Find it with your favourite package manager, eg:
#+BEGIN_SRC shell
nix-env --install sbt
#+END_SRC
or refer to [[http://www.scala-sbt.org/download.html][the sbt installation instructions]].
*** Installation when using Gradle
Refer to the [[https://web.archive.org/web/20190324005432/http://ensime.github.io/build_tools/gradle/][Ensime installation instructions]] to install the =ensime-gradle=
plugin.
*** Configuration
Follow [[https://web.archive.org/web/20190417132406/http://ensime.github.io/build_tools/sbt/][the ENSIME configuration instructions]]. Spacemacs uses
the development version of Ensime so follow the appropriate steps.
To use the build functions under ~SPC m b~ you need to use version =0.13.5= or
newer of =sbt=, and specify that in your project's =project/build.properties=.
For example,
#+BEGIN_SRC scala
sbt.version=0.13.11
#+END_SRC
*** Usage
~SPC SPC spacemacs/ensime-gen-and-restart~ or ~SPC m D r~ generates a new config
for a project and starts the server. Afterwards ~SPC SPC ensime~ or ~SPC m D s~
will suffice do the trick.
* Scalastyle
[[http://www.scalastyle.org/][Scalastyle]] provides style-checking and linting. The Emacs functionality is
provided by Flycheck.
@ -185,17 +104,6 @@ To enable =java-doc-style=, set the variable =scala-indent:use-javadoc-style= to
* Enable Debug Adapter Protocol (DAP)
The metals backend enables integration with the DAP layer for debugging support.
* Automatically show the type of the symbol under the cursor
To enable the feature =ensime-type-at-point= when cursor moves, set the
variable =scala-enable-eldoc= to =t=.
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(scala :variables scala-enable-eldoc t)))
#+END_SRC
Enabling this option can cause slow editor performance.
* Automatically insert asterisk in multiline comments
To insert a leading asterisk in multiline comments automatically, set the
variable =scala-auto-insert-asterisk-in-comments= to =t=.
@ -205,163 +113,20 @@ variable =scala-auto-insert-asterisk-in-comments= to =t=.
(scala :variables scala-auto-insert-asterisk-in-comments t)))
#+END_SRC
* Deprecated: Automatic replacement of arrows with Unicode ones
Scala used to support Unicode arrows =⇒=, =→= as aliases for ~=>~, =->= and =<-=, and the
Scala layer would do the conversion to Unicode for you if you set
=scala-use-unicode-arrows= to =t=. As the Unicode arrows are now [[https://github.com/scala/scala/pull/7540][deprecated]] in
Scala, this variable has been dropped from the Scala layer. If it is still in
your Scala layer variables like so:
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(scala :variables scala-use-unicode-arrows t)))
#+END_SRC
Then you will need to remove it:
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(scala))
#+END_SRC
* Enable GTags as a fallback navigation utility
To enable gtags when in scala-mode, in case metals, or, ensime are not fully
functioning set the variable =scala-enable-gtags= to =t=.
To enable gtags when in =scala-mode= set the variable =scala-enable-gtags= to =t=.
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(scala :variables scala-enable-gtags t)))
#+END_SRC
* Auto-start
If you prefer to have the backend start when you load a scala file, you can enable it
with
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(scala :variables scala-auto-start-backend t)))
#+END_SRC
* Key bindings
** Ensime
*** Search
Additional major mode keybindings are populated by LSP and DAP.
| Key binding | Description |
|-------------+-----------------------------------------------------|
| ~SPC m /~ | incremental search using =ensime-scalex= major mode |
| ~SPC m ?~ | incremental search in all live buffers |
** sbt
*** Ensime Search Mode
| Key binding | Description |
|-------------+-------------------------------------------------------------------|
| ~C-j~ | Move to next match |
| ~C-k~ | Move to previous match |
| ~C-i~ | Insert at point import of current result |
| ~RET~ | Jump to the target of the currently selected ensime-search-result |
| ~C-q~ | Quit ensime search |
*** sbt
| Key binding | Description |
|-------------+---------------------|
| ~SPC m b .~ | sbt transient state |
| ~SPC m b b~ | sbt command |
| ~SPC m b c~ | compile |
| ~SPC m b C~ | clean command |
| ~SPC m b i~ | switch to sbt shell |
| ~SPC m b p~ | package command |
| ~SPC m b r~ | run command |
*** Typecheck
| Key binding | Description |
|-------------+-----------------------------|
| ~SPC m c t~ | type check the current file |
*** Debug
| Key binding | Description |
|-------------+-----------------------------|
| ~SPC m d A~ | Attach to a remote debugger |
| ~SPC m d b~ | set breakpoint |
| ~SPC m d B~ | clear breakpoint |
| ~SPC m d C~ | clear all breakpoints |
| ~SPC m d c~ | continue |
| ~SPC m d i~ | inspect value at point |
| ~SPC m d n~ | next |
| ~SPC m d o~ | step out |
| ~SPC m d q~ | quit |
| ~SPC m d r~ | run |
| ~SPC m d s~ | step |
| ~SPC m d t~ | backtrace |
*Note:* These key bindings need a transient-state, PR welcome :-)
*** Errors
| Key binding | Description |
|-------------+----------------------------------------------------|
| ~SPC m e e~ | print error at point |
| ~SPC m e s~ | switch to buffer containing the stack trace parser |
*** Goto
| Key binding | Description |
|-------------+------------------|
| ~SPC m g g~ | go to definition |
*** Print and yank types
|-------------+--------------------------------|
| ~SPC m h T~ | print full type name at point |
| ~SPC m h t~ | print short type name at point |
| ~SPC m y T~ | yank full type name at point |
| ~SPC m y t~ | yank short type name at point |
*** Documentation, Inspect
| Key binding | Description |
|-------------+----------------------------------------|
| ~SPC m h h~ | show documentation for symbol at point |
| ~SPC m h u~ | show uses for symbol at point |
*** Server
| Key binding | Description |
|-------------+--------------------------------------------------------|
| ~SPC m D f~ | reload open files |
| ~SPC m D r~ | regenerate the =.ensime= and restart the ensime server |
| ~SPC m D s~ | start ensime server |
*** Refactoring
| Key binding | Description |
|-------------+----------------------------------------------------------------------|
| ~SPC m r a~ | add type annotation |
| ~SPC m r d~ | get rid of an intermediate variable (=ensime-refactor-inline-local=) |
| ~SPC m r D~ | get rid of an intermediate variable (=ensime-undo-peek=) |
| ~SPC m r i~ | organize imports |
| ~SPC m r m~ | extract a range of code into a method |
| ~SPC m r r~ | rename a symbol project wide |
| ~SPC m r t~ | import type at point |
| ~SPC m r v~ | extract a range of code into a variable |
| ~SPC m z~ | expand/contract region |
*** Tests
| Key binding | Description |
|-------------+--------------------------|
| ~SPC m t a~ | test command (sbt) |
| ~SPC m t r~ | test quick command (sbt) |
| ~SPC m t t~ | test only (sbt) |
*** REPL
| Key binding | Description |
|-------------+---------------------------------------------------------------------|
| ~SPC m s a~ | ask for a file to be loaded in the REPL |
| ~SPC m s b~ | send buffer to the REPL |
| ~SPC m s B~ | send buffer to the REPL and focus the REPL buffer in =insert state= |
| ~SPC m s i~ | start or switch to the REPL inferior process |
| ~SPC m s r~ | send region to the REPL |
| ~SPC m s R~ | send region to the REPL and focus the REPL buffer in =insert state= |
| Key binding | Description |
|-------------+------------------------|
| ~SPC m b .~ | sbt transient state |
| ~SPC m b b~ | sbt command |

View File

@ -11,9 +11,6 @@
(spacemacs|define-jump-handlers scala-mode)
(defvar scala-enable-eldoc nil
"If non nil then eldoc-mode is enabled in the scala layer.")
(defvar scala-enable-gtags nil
"If non nil then gtags is enabled in the scala layer.")
@ -25,15 +22,12 @@ small window at the bottom of the frame.")
(defvar scala-auto-insert-asterisk-in-comments nil
"If non-nil automatically insert leading asterisk in multi-line comments.")
(defconst scala-backends '(scala-ensime scala-metals)
(defconst scala-backends '(scala-metals)
"Backend server implementation to enable advanced IDE language features")
(defvar scala-backend 'scala-ensime
(defvar scala-backend 'scala-metals
"Backend used to trigger IDE language features.
`scala-ensime' or `scala-metals' are currently supported")
(defvar scala-auto-start-backend nil
"If non nil then ensime/metals will be started when a scala file is opened.")
Only `scala-metals' is currently supported.")
(defvar scala-auto-treeview t
"If non-nil automatically show treeview when views are recieved by metals.")

View File

@ -9,47 +9,8 @@
;;
;;; License: GPLv3
(autoload 'ensime-config-find-file "ensime-config")
(autoload 'ensime-config-find "ensime-config")
(autoload 'projectile-project-p "projectile")
(defun spacemacs//ensime-maybe-start ()
(when (buffer-file-name)
(let ((ensime-buffer (spacemacs//ensime-buffer-for-file (buffer-file-name)))
(file (ensime-config-find-file (buffer-file-name)))
(is-source-file (s-matches? (rx (or "/src/" "/test/"))
(buffer-file-name))))
(when (and is-source-file (null ensime-buffer))
(noflet ((ensime-config-find (&rest _) file))
(save-window-excursion
(ensime)))))))
(defun spacemacs//ensime-buffer-for-file (file)
"Find the Ensime server buffer corresponding to FILE."
(let ((default-directory (file-name-directory file)))
(-when-let (project-name (projectile-project-p))
(--first (-when-let (bufname (buffer-name it))
(and (s-contains? "inferior-ensime-server" bufname)
(s-contains? (file-name-nondirectory project-name)
bufname)))
(buffer-list)))))
(defun spacemacs//ensime-flyspell-verify ()
"Prevent common flyspell false positives in scala-mode."
(and (flyspell-generic-progmode-verify)
(not (s-matches? (rx bol (* space) "package") (current-line)))))
(defun spacemacs//scala-setup-ensime ()
"Setup ENSIME."
(add-to-list 'spacemacs-jump-handlers-scala-mode 'ensime-edit-definition)
;; ensure the file exists before starting `ensime-mode'
(cond
((and (buffer-file-name) (file-exists-p (buffer-file-name)))
(ensime-mode))
((buffer-file-name)
(add-hook 'after-save-hook 'ensime-mode nil t))))
(defun spacemacs//scala-setup-metals ()
"Setup LSP metals for Scala."
(add-hook 'scala-mode-hook #'lsp))
@ -70,13 +31,6 @@ For use with `sbt:display-buffer-action'."
"Setup lsp-treemacs for Scala."
(setq lsp-metals-treeview-show-when-views-received scala-auto-treeview))
(defun spacemacs//scala-disable-flycheck-scala ()
(push 'scala flycheck-disabled-checkers))
(defun spacemacs//scala-backend-ensime-p ()
"Return true if the selected backend is ensime"
(eq scala-backend 'scala-ensime))
(defun spacemacs//scala-backend-metals-p ()
"Return true if the selected backend is metals"
(eq scala-backend 'scala-metals))
@ -101,71 +55,3 @@ point to the position of the join."
(when join-pos
(goto-char join-pos))))
(defun spacemacs//scala-setup-ensime-flyspell ()
"Setup ENSIME spell checking."
(flyspell-mode)
(setq-local flyspell-generic-check-word-predicate
'spacemacs//ensime-flyspell-verify))
(defun spacemacs//scala-setup-ensime-eldoc ()
"Setup ENSIME eldoc."
(setq-local eldoc-documentation-function
(lambda ()
(when (ensime-connected-p)
(ensime-type-at-point))))
(eldoc-mode))
;; interactive functions
(defun spacemacs/ensime-gen-and-restart()
"Regenerate `.ensime' file and restart the ensime server."
(interactive)
(progn
(sbt-command ";ensimeConfig;ensimeConfigProject")
(ensime-shutdown)
(ensime)))
(defun spacemacs/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 spacemacs/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))
(defun spacemacs/ensime-refactor-accept ()
(interactive)
(funcall continue-refactor)
(ensime-popup-buffer-quit-function))
(defun spacemacs/ensime-refactor-cancel ()
(interactive)
(funcall cancel-refactor)
(ensime-popup-buffer-quit-function))
(defun spacemacs/ensime-completing-dot ()
"Insert a period and show company completions."
(interactive "*")
(when (s-matches? (rx (+ (not space)))
(buffer-substring (line-beginning-position) (point)))
(delete-horizontal-space t))
(company-abort)
(insert ".")
(company-complete))
(defun spacemacs/ensime-yank-type-at-point ()
"Yank to kill ring and print short type name at point to the minibuffer."
(interactive)
(ensime-type-at-point '(4)))
(defun spacemacs/ensime-yank-type-at-point-full-name ()
"Yank to kill ring and print full type name at point to the minibuffer."
(interactive)
(ensime-type-at-point '(4) t))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

@ -9,7 +9,7 @@
;;
;;; License: GPLv3
(configuration-layer/declare-layer-dependencies '(java))
(configuration-layer/declare-layer-dependencies '(java lsp))
(when (and (boundp 'scala-backend)
(eq scala-backend 'scala-metals))

View File

@ -12,172 +12,27 @@
(defconst scala-packages
'(
lsp-mode
(lsp-metals :toggle (spacemacs//scala-backend-metals-p))
lsp-metals
dap-mode
eldoc
flycheck
flyspell
counsel-gtags
ggtags
helm-gtags
(ensime :toggle (spacemacs//scala-backend-ensime-p))
sbt-mode
scala-mode))
(defun scala/post-init-eldoc ()
(when (and scala-enable-eldoc (spacemacs//scala-backend-ensime-p))
(add-hook 'scala-mode-hook #'spacemacs//scala-setup-ensime-eldoc)))
(defun scala/init-ensime ()
(use-package ensime
:defer t
:if (spacemacs//scala-backend-ensime-p)
:init
(progn
(setq ensime-startup-dirname (concat spacemacs-cache-directory "ensime/"))
(spacemacs/register-repl 'ensime 'ensime-inf-switch "ensime")
(add-hook 'scala-mode-hook #'spacemacs//scala-setup-ensime)
(when scala-auto-start-backend
(add-hook 'scala-mode-hook 'spacemacs//ensime-maybe-start)))
:config
(progn
;; This function was renamed in ensime. Usually we don't need to do this,
;; but documentation recommends the stable version of ensime, so we must
;; try to support it, too.
(unless (fboundp 'ensime-type-at-point)
(defalias 'ensime-type-at-point 'ensime-print-type-at-point))
;; key bindings
(dolist (mode '(scala-mode))
(dolist (prefix '(("mb" . "build")
("mc" . "check")
("md" . "debug")
("mD" . "daemon")
("mE" . "errors")
("mg" . "goto")
("mh" . "docs")
("mi" . "inspect")
("mr" . "refactor")
("mt" . "test")
("ms" . "repl")
("my" . "yank")))
(spacemacs/declare-prefix-for-mode mode (car prefix) (cdr prefix)))
(spacemacs/set-leader-keys-for-major-mode mode
"/" 'ensime-search
"'" 'ensime-inf-switch
"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-buffer
"dA" 'ensime-db-attach
"db" 'ensime-db-set-break
"dB" 'ensime-db-clear-break
"dC" 'ensime-db-clear-all-breaks
"dc" 'ensime-db-continue
"di" 'ensime-db-inspect-value-at-point
"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
"Df" 'ensime-reload-open-files
"Dr" 'spacemacs/ensime-gen-and-restart
"Ds" 'ensime
"Ee" 'ensime-print-errors-at-point
"Es" 'ensime-stacktrace-switch
"gp" 'ensime-pop-find-definition-stack
"hh" 'ensime-show-doc-for-symbol-at-point
"hT" 'ensime-type-at-point-full-name
"ht" 'ensime-type-at-point
"hu" 'ensime-show-uses-of-symbol-at-point
"ra" 'ensime-refactor-add-type-annotation
"rd" 'ensime-refactor-diff-inline-local
"rD" 'ensime-undo-peek
"ri" 'ensime-refactor-diff-organize-imports
"rm" 'ensime-refactor-diff-extract-method
"rr" 'ensime-refactor-diff-rename
"rt" 'ensime-import-type-at-point
"rv" 'ensime-refactor-diff-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" 'spacemacs/ensime-inf-eval-buffer-switch
"si" 'ensime-inf-switch
"sr" 'ensime-inf-eval-region
"sR" 'spacemacs/ensime-inf-eval-region-switch
"yT" 'spacemacs/ensime-yank-type-at-point-full-name
"yt" 'spacemacs/ensime-yank-type-at-point
"z" 'ensime-expand-selection-command))
(evil-define-key 'insert ensime-mode-map
(kbd ".") 'spacemacs/ensime-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)
(evil-define-key 'normal ensime-popup-buffer-map
(kbd "q") 'ensime-popup-buffer-quit-function)
(evil-define-key 'normal ensime-inspector-mode-map
(kbd "q") 'ensime-popup-buffer-quit-function)
(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
(kbd "M-p") 'backward-button
(kbd "n") 'forward-button
(kbd "N") 'backward-button)
(evil-define-key '(insert normal) ensime-search-mode-map
(kbd "C-q") 'ensime-search-quit
(kbd "C-j") 'ensime-search-next-match
(kbd "C-k") 'ensime-search-prev-match
(kbd "RET") 'ensime-search-choose-current-result
(kbd "C-i") 'ensime-search-insert-import-of-current-result)
;; Enable Expand Region integration from Ensime. Ignore load errors to
;; handle older Ensime versions gracefully.
(when (configuration-layer/package-used-p 'expand-region)
(require 'ensime-expand-region nil 'noerror)))))
(defun scala/post-init-flycheck ()
(spacemacs/enable-flycheck 'scala-mode)
;; Don't use scala checker if ensime mode is active, since it provides
;; better error checking.
(when (spacemacs//scala-backend-ensime-p)
(with-eval-after-load 'flycheck
(add-hook 'ensime-mode-hook 'spacemacs//scala-disable-flycheck-scala))))
(spacemacs/enable-flycheck 'scala-mode))
(defun scala/post-init-flyspell ()
(spell-checking/add-flyspell-hook 'scala-mode)
(when (spacemacs//scala-backend-ensime-p)
(add-hook 'scala-mode-hook #'spacemacs//scala-setup-ensime-flyspell)))
(spell-checking/add-flyspell-hook 'scala-mode))
(defun scala/init-sbt-mode ()
(use-package sbt-mode
:defer t
:config
;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
;; WORKAROUND: https://github.com/hvesalai/emacs-sbt-mode/issues/31
;; allows for using SPACE in the minibuffer
(substitute-key-definition
'minibuffer-complete-word
@ -202,14 +57,6 @@
(add-to-list 'completion-ignored-extensions ext)))
:config
(progn
;; Ensure only one of metals and ensime is loaded
(unless (spacemacs//scala-backend-ensime-p)
(progn
(fmakunbound 'ensime)
(remove-hook 'after-change-functions 'ensime-after-change-function)
(remove-hook 'window-configuration-change-hook
'ensime-show-left-margin-hook)))
;; Automatically insert asterisk in a comment when enabled
(defun scala/newline-and-indent-with-asterisk ()
(interactive)

View File

@ -2235,19 +2235,15 @@ This layer adds support for the Scala language to Spacemacs.
Features:
- Syntax highlighting
- Support for language backend. Either using [[https://ensime.github.io/][ENSIME]] or [[https://scalameta.org/metals/][Metals]]
- Debugging support via dap
- Support for language backend using LSP and [[https://scalameta.org/metals/][Metals]]
- Debugging support via =dap=
- Auto-completion
- Treeview support for viewing project structure and triggering compilation
- Syntax-checking
- Refactoring
- Incremental compilation
- Scala Repl
- Style linting
- Eldoc integration
- Optional GGTags search
- Test execution directly from Emacs
- Automatic replacement of ASCII arrows with unicode ones
**** SML
[[file:+lang/sml/README.org][+lang/sml/README.org]]
@ -3067,12 +3063,12 @@ Features:
** Tide Layer
[[file:+tools/tide/README.org][+tools/tide/README.org]]
This layer installs [[https://github.com/ananthakumaran/tide][tide]] package which allows communication with
This layer installs [[https://github.com/ananthakumaran/tide][tide]] package which allows communication with
[[https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29][standalone typescript server]] =tsserver= for JavaScript/TypeScript development.
Features:
- First class support from =tsserver= just like =vscode=: speed and accuracy
- Linter
- Linter
- Refactor
- Go to definition
- Find references