Skip to content

Instantly share code, notes, and snippets.

@d6y
Last active November 16, 2016 11:41
Show Gist options
  • Save d6y/858fa132dc9347301a5b to your computer and use it in GitHub Desktop.
Save d6y/858fa132dc9347301a5b to your computer and use it in GitHub Desktop.
Spacemacs: Notes made during install

Spacecmacs, VIM editor plus a crapton of plugins for Scala

Useful:

One Time Set Up

Install MacEmacs http://emacsformacosx.com/

Set up the command line: http://emacsformacosx.com/tips

Do the clone thing in the spacemacs guide. https://github.com/syl20bnr/spacemacs

Start spaceemacs and press return when asked about evil mode or emacs mode (you want evil)

Edit ~/.spacemacs

(nb the themes megapack produces a lot of messages)

   dotspacemacs-configuration-layers
   '(
     scala
     git
     osx
     markdown
     javascript
     themes-megapack

     ;; --------------------------------------------------------
     ;; Example of useful layers you may want to use right away
     ;; Uncomment a layer name and press C-c C-c to install it
     ;; --------------------------------------------------------
     ;; auto-completion
     ;; better-defaults
     ;; (git :variables
     ;;      git-gutter-use-fringe t)
   etc

Save, and restart. Ensime will download

For spell checking: $ brew install aspell

Install SBT plugin:

edit ~/.sbt/0.13/plugins/build.sbt

add:

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

Per Project

In your SBT project, run gen-ensime (generates a .ensime file)

Clues

Colours have meaning. Bottom right (and cursor): orange (default mode), green insert mode

space = global command key (the "leader key") e.g.,

  • space b ... brings up list of comands to do with buffers
  • space f ... bring up list of commands to do with f
  • space f r - list of recent files
  • space f S - save all buffers
  • space w 2 - two column layout
  • space 1 - switch to buffer 1 (or click in it.. buffer number is shown bottom right)
  • space b d - close (delete?) the buffer
  • space : - same as meta key on Emacs

Sample workflow:

  • space w - (split window below) or space w / (split right)
  • space f r (select recent file to edit)

Scala

In Emacs, edit a Scala file in your project. Ensime starts, should have syntax highlighting.

https://github.com/syl20bnr/spacemacs/tree/master/contrib/lang/scala

Ctrl-Click to jump to source See: http://ensime.github.io/

SBT

You must have a project/build.properties file

Then... space : sbt-start to start sbt Ctrl-n / p = go to next and previous errors

https://github.com/hvesalai/sbt-mode

Editing

TODO:

  • how to get hash key working on UK keyboard.

Search

Usual / and ?, but <spc> sc to clear any persistent highlighting.

<n>G to jump to line n. Eg 121G

Quickly change font size

Ctrl-x Ctrl-+ and Ctrl-x Ctrl--

or

<spc> z x and then repeatedly as required use = (reset), + (increase), and - (decrease). Any other key to leave this mode.

Multiple cursors

E.g., put our cursor on cat below, do do

  • <spc> s e (switches to iedit mode, red)

  • L (restrict to current line, excluding the word cat <- here)

  • S (substitute) dog ESC ESC (should replace cats with dogs)

    The cat sat on the cat by the cat

Block mode

E.g., go to the < in <- f below. Press Ctrl-v, then down cursor to select the next line. Go into insert mode by pressing I, tap space then ESC You have aligned the generators.

for { a <- f b <- g why <- h } yield a * b / why

More config

edit .spacemacs file and in the config section at the endd add:

 (add-hook 'before-save-hook 'delete-trailing-whitespace)
 (global-linum-mode)
 (setq tab-width 2)

;;; From http://stackoverflow.com/questions/24921390/how-to-get-emacs-to-automatically-load-and-save-desktop-from-initial-directory
(setq your-own-path default-directory)
(if (file-exists-p
     (concat your-own-path ".emacs.desktop"))
    (desktop-read your-own-path))

(add-hook 'kill-emacs-hook
      `(lambda ()
        (desktop-save ,your-own-path t)))

also set default theme:

dotspacemacs-themes '(subatomic256)

...or monochrome or whatever theme you want from the megapack

Ctrl-C Ctrl-C to reload

, = context sensitive key for commands in say scala

Files

<spc> p t bring up file navigator thingy as buffer/window 0.

Changing working dir

Set working directory to your SBT project E.g.,

  • space : cd
  • type then right arrow to select and navigate, return to select a directory
@oivoodoo
Copy link

oivoodoo commented Sep 2, 2015

@d6y have you tried to setup auto-completion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment