This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/scala
Miciah Masters e0b751bee3 Avoid non-idempotent use of push in init code
Replace push with add-to-list in layer init functions and related code.

Modify spacemacs|add-toggle to check for and update an existing toggle in
spacemacs-toggles and only create a new toggle if none already existed.

Replace a conditional push onto erc-packages with use of :toggle.

When initializing which-key, set which-key-replacement-alist to its default
or customized setting before adding all the Spacemacs replacements.  We
want to keep the stock replacements but avoid adding duplicates of the
Spacemacs replacements.

Replace the emacs-lisp-mode-hook lambda with a named function to avoid
adding duplicate hooks (which can add duplicate definitions of the
evil-surround pair).
2018-06-05 22:17:13 -04:00
..
img
config.el Happy New Year 2018! 2018-01-04 02:00:25 -05:00
funcs.el Happy New Year 2018! 2018-01-04 02:00:25 -05:00
layers.el Happy New Year 2018! 2018-01-04 02:00:25 -05:00
packages.el Revert "Defer packages by default using use-package-always-defer" 2018-03-03 23:40:10 -05:00
README.org Avoid non-idempotent use of push in init code 2018-06-05 22:17:13 -04:00

Scala layer

/TakeV/spacemacs/media/commit/ae53d9612eede1e3d94c1c9b291a119ac1515fdc/layers/+lang/scala/img/scala.png with /TakeV/spacemacs/media/commit/ae53d9612eede1e3d94c1c9b291a119ac1515fdc/layers/+lang/scala/img/ensime.png

Description

This layer adds support for the Scala language to Spacemacs.

Features:

  • Syntax highlighting
  • Auto-completion
  • Syntax-checking
  • Refactoring
  • Incremental compilation
  • Scala Repl
  • Style linting
  • Eldoc integration
  • Test execution directly from emacs
  • Automatic replacement of ASCII arrows with unicode ones
  • Automatic starting/stopping of ENSIME IDE server

Layer Installation

To use this configuration layer, add it to your ~/.spacemacs. You will need to add scala to the existing dotspacemacs-configuration-layers list in this file.

Then, you should modify your ~/.spacemacs to use the recommended Ensime version (Stable). Please add the following lines to dotspacemacs/user-init:

  (add-to-list 'configuration-layer-elpa-archives '("melpa-stable" . "stable.melpa.org/packages/"))
  (add-to-list 'package-pinned-packages '(ensime . "melpa-stable"))

Ensime

ENSIME provides IDE-like features, such as refactoring, incremental compilation and project-wide type-checking.

ENSIME requires a configuration file at the root of each Scala project. It provides an SBT plugin, a gradle plugin and others (see ensime.org for a full list) to generate these files.

Installation instructions and usage can be found in the Java layer README.org.

Scalastyle

Scalastyle provides style-checking and linting. The Emacs functionality is provided by Flycheck.

To use scalastyle, it must be present as an executable in your PATH.

To test if scalastyle executable is in your path, run scalastyle in a new terminal, it should output something like:

$ scalastyle
scalastyle 0.8.0
Usage: scalastyle [options] <source directory>
...

Finally, enable the syntax-checking layer and set the flycheck-scalastylerc variable to a valid location.

  (setq-default flycheck-scalastylerc "/usr/local/etc/scalastyle_config.xml")

See the flycheck documentation and scalastyle configuration for up-to-date configuration instructions.

Use Java doc-style

To enable java-doc-style, set the variable scala-indent:use-javadoc-style to t

  (setq-default dotspacemacs-configuration-layers '(
    (scala :variables scala-indent:use-javadoc-style t)))

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.

  (setq-default dotspacemacs-configuration-layers '(
    (scala :variables scala-enable-eldoc t)))

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.

  (setq-default dotspacemacs-configuration-layers '(
    (scala :variables scala-auto-insert-asterisk-in-comments t)))

Automatically replace arrows with unicode ones

To replace =>, -> and <- with unicode arrows , and , set the variable scala-use-unicode-arrows to t.

If in some occasions you don't want the arrows replaced (for example when defining compound operators like =>>), you can always undo the change and get the ascii arrows back.

  (setq-default dotspacemacs-configuration-layers '(
    (scala :variables scala-use-unicode-arrows t)))

Auto-start

If you prefer to have Ensime start when you load a scala file, you can enable it with

(setq-default dotspacemacs-configuration-layers '(
    (scala :variables scala-auto-start-ensime t)))

Key bindings

All ensime key bindings are listed in the java layer README.org.