spacemacs/layers/+lang/scala
syl20bnr 82fdd9a511 Use evil in holy-mode
Motivation

While disabling Evil in holy-mode makes its implementation shorter and
sounds elegant on the paper, in practice it puts a big burden on the
configuration parts which need to know if Evil is enable or not. This is
a bad separation of concerns and the bunch of fixes that we were forced
to do in the past weeks shows this issue. Those fixes were about
removing the knowledge of the activation of Evil by implementing new
dispatching functions to be used by layers, this is cumbersome and makes
Spacemacs layer configuration more subtle which is not good. There was
additional bad consequences of the removal of Evil state like the
impossibility to use Evil lisp state or iedit states, or we would have
been forced to implement a temporary activation of Evil which is
awkward.

Instead I reintroduce Evil as the central piece of Spacemacs design thus
Evil is now re-enabled in holy-mode. It provides the abstraction we need
to isolate editing styles and be able to grow the Spacemacs
configuration coverage sanely. Layers don't need to check whether the
holy mode is active or not and they don't need to know if Evil is
available (it is always available). We also don't need to write
additional dispatching functions, this is the job of Evil, and I think
it provides everything for this. Ideally configuration layer should be
implemented with only Evil in mind and the holy-mode (and hybrid-mode)
should magically make it work for Emacs style users, for instance we can
freely use `evil-insert-state` anywhere in the code without any guard.

Evil is now even more part of Spacemacs, we can really say that
Spacemacs is Emacs+Evil which is now an indivisible pair. Spacemacs
needed this stable API to continue on the right track.

While these changes should be rather transparent to the user, I'm sorry
for this experimental period, I failed to see all the implications of
such a change, I was just excited about the possibility to make Evil
optional. The reality is that Spacemacs has to embrace it and keep its
strong position on being Emacs+Evil at the core.

Implementation

- insert, motion and normal states are forced to emacs state using an
advice on `evil-insert-state`, `evil-motion-state` and
`evil-normal-state` respectively. These functions can be used freely in
the layer configuration.
- A new general hook `spacemacs-editing-style-hook` allow to hook any
code that need to be configured based on the editing style. Functions
hooked to this hook takes the current style as parameter, this
basically generalize the hook used to setup hjkl navigation bindings.
- ESC has been removed from the emacs state map.
- Revert unneeded changes
  - Revert "evil: enter insert-state only from normal-state"
    commit bdd702dfbe.
  - Revert "avoid being evil in deft with emacs editing style"
    commit f3a16f49ed.

Additional changes

All editing style packages have been moved to a layer called
`spacemacs-editing-styles`

Notes

I did not have time to attack hybrid mode, I should be able to do it
later.
2016-03-13 21:16:55 -04:00
..
img
config.el
funcs.el
packages.el Use evil in holy-mode 2016-03-13 21:16:55 -04:00
README.org

Scala layer

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

Description

This layer adds support for the Scala language using the excellent ENSIME client/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.

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 to generate these files.

Installation

Configure the ENSIME sbt plugin by adding the following to ~/.sbt/0.13/plugins/plugins.sbt:

  addSbtPlugin("org.ensime" % "ensime-sbt" % "0.2.3")

Please go to ensime-sbt Github Page to check the latest version of ensime-sbt plugin.

Please note your projects' project/build.properties need to use a version newer that 0.13.5 of sbt.

  sbt.version=0.13.9

Usage

  1. Create a .ensime file at the root of your Scala project using sbt gen-ensime at the shell.
  2. Run M-x ensime within Emacs to start an ENSIME session.

Each Scala project uses a dedicated ENSIME session, so you only need to run M-x ensime once per project. Any Scala files you create or visit within the project will automatically use ENSIME for the remainder of your editing session.

Scalastyle

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

To use scalastyle,

  1. Download the scalastyle jar and put it somewhere sensible
  2. Customise the flycheck-scalastyle-jar variable and set it to the path of the jar.

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

Automatically show the type of the symbol under the cursor

To enable the feature ensime-print-type-at-point when cursor moves, set the variable scala-enable-eldoc-mode to t.

  (setq-default dotspacemacs-configuration-layers '(
    (scala :variables scala-enable-eldoc-mode 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)))

Key bindings

Ensime key bindings

Search

Key Binding Description
SPC m / incremental search using ensime-scalex major mode
SPC m ? incremental search in all live buffers

sbt

Key Binding Description
SPC m b c compile command
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
SPC m c T type check all the open buffers

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 d start a debug session
SPC m d i inspect value at point
SPC m d l list local variables
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 l show all errors and warnings
SPC m e s switch to buffer containing the stack trace parser

Goto

Key Binding Description
SPC m g g go to definition
SPC m g i go to implementation
SPC m g t go to test

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
SPC m h t print type at point
SPC m i i inspect type at point
SPC m i I inspect type in other frame
SPC m i p inspect project package

Server

Key Binding Description
SPC m n F reload open files
SPC m n s start ensime server
SPC m n S regenerate the .ensime and restart the ensime server

Refactoring

Key Binding Description
SPC m r f format source
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