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)
 ;; markdown
 ;; org
 ;; syntax-checking

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 righti (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

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

space :   - same as meta key on Emacs

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 quickly/easily increase/decrease font size.
  • how to get hash key working on UK keyboard.

Multiple cursors: https://github.com/tsdh/iedit https://github.com/syl20bnr/evil-iedit-state

E.g., put our cursor on cat below, do do space se (switches to iedit mode, red) L (restrict to current line, excluding the word cat <- here) S dog ESC ESC (replace all)

The cat sat on the cat by the cat

Fixing indent

(TODO: figure this one out... how to position at first <- and indent it and the next line to align with <- flip)

for { x <- f dummy <- brad y <- flip } yield 9

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 whatever list of themes you want from the megapack

Ctrl-C Ctrl-C to reload

, = context sensitive key for commands in say scala

Files

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