AstonJ

AstonJ

A wiki for Spacemacs

Spacemacs with Alchemist is an extremely popular set-up to use for Elixir development. Give it a try by following our guide here and let us know what you think!

http://spacemacs.org - Official SpaceMacs site
http://www.alchemist-elixir.org - Alchemist Elixir site


Installation

We need to install Emacs first, then Spacemacs, then add the Elixir layer to SpaceMacs:

1) Emacs installation

Here are the instructions for OS X (from their wiki). For other platforms look here.

Usual Emacs installation:

brew update
brew install emacs --with-cocoa
brew linkapps emacs

Or, SpaceMacs recommended installation (includes SpaceMacs icon etc):

$ brew tap d12frosted/emacs-plus
$ brew install emacs-plus
$ brew linkapps emacs-plus

2) Spacemacs installation

Then simply backup your original emacs.d folder and install Spacemacs with:

mv ~/.emacs.d ~/.emacs.backup
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d

Once that is done, start Emacs and let it install everything, then restart and Spacemacs config will kick in. Select VIM mode when it asks you.

3) Adding the Elixir layer

Open up your ~/.spacemacs file, and under dotspacemacs-configuration-layers simply add elixir. It should look something like this:

   dotspacemacs-configuration-layers
   '(
     ruby
     ;; ----------------------------------------------------------------
     ;; Example of useful layers you may want to use right away.
     ;; Uncomment some layer names and press <SPC f e R> (Vim style) or
     ;; <M-m f e R> (Emacs style) to install them.
     ;; ----------------------------------------------------------------
     helm
     ;; auto-completion
     ;; better-defaults
     emacs-lisp
     ;; git
     ;; markdown
     ;; org
     ;; (shell :variables
     ;;        shell-default-height 30
     ;;        shell-default-position 'bottom)
     ;; spell-checking
     ;; syntax-checking
     ;; version-control
     elixir
     )

Then simply restart SpaceMacs and it will install everything. That’s it, you now have SpaceMacs installed!!

4) Install Ack or Ag

This will speed up search significantly.

Ack is a tool like grep, optimized for programmers.
Ag is like Ack, but claims to be 5-10x faster.

I’ve opted for Ag, install it in OS X with brew install the_silver_searcher

5) Optional - enable smooth scrolling, NeoTree to right and session restore

Smooth scrolling (source)

Simply add the last 5 lines below to your user-config to defun dotspacemacs/user-config () to end up with something like:

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
  ;; scroll one line at a time (less "jumpy" than defaults)
  (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
  (setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
  (setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
  (setq scroll-step 1) ;; keyboard scroll one line at a time
  )

NeoTree on right hand side

If you would like your NeoTree SPC f t to open on the right hand side simple add '(neo-window-position (quote right)) to you custom-set-variables in your .spacemacs file (then restart or reload).

Session restore

Set dotspacemacs-auto-resume-layouts to t in your .spacemacs - this will restore your session when you open SpaceMacs. (You may or may not like this - might be an idea to try it without for a while first.)

6) For Mac users

Adding a font

The default font does not seem to be one shipped with OS X, so open your .spacemacs file (which can also be opened from within SpaceMacs with SPC f e d and under dotspacemacs-default-font swap the font to “Menlo” and change the size to 12.

Adding the OSX layer

In layers, add osx as this will add some common Mac keybindings (such as command and w to close a window, command and + or - to increase/decrease font size etc.

For those with British Keyboards

Add the following to your user-config so that you can use ALT+3 for the hash key:

  ;; Allow hash to be entered
  (define-key window-numbering-keymap (kbd "M-3") nil) 
  (global-set-key (kbd "M-3") (lambda () (interactive) (insert "#")))

Making the Emacs shell respect your .bash_profile

Install exec-path-from-shell by SPC SPC package-install (then start typing exec-path-from-shell)
Then open or create a .bashrc file and at the bottom add . ~/.bash_profile


Getting started with Spacemacs and documentation


Installing packages

Find the package you want to install on Melpa (the Emacs Package Manager) and then check it is not already installed by SPC h SPC followed by the package name. If it’s not…

  • If it’s a layer add it to the layers list in your .spacemacs file and restart
  • Otherwise hit SPC SPC <package name> RET and it will install it

Most packages are on Melpa and included by SpaceMacs, but if not, you can add the package name to dotspacemacs-additional-packages and restart to see if it installs, if not then additionally add any downloadable associated files to a directory in your load path.


Spacemacs quick tips

See the thread for more, here are a few worth pointing out:

Opening and reloading config

  • You can open your .spacemacs file from within SpaceMacs with SPC f e d
  • After making changes with the above, you can use SPC f e R to reload your config (saves having to restart it - but if you want to restart it, you can do SPC q r)

Lookup, viewing docs and misc

  • SPC h SPC to open documentation
  • Need to lookup up an Emacs function? If you are curious as to what a function is bound to, you can do SPC h d f name-of-function RETURN, e.g. SPC h d f what-cursor-position RETURN
  • When you see things that ask you to do something like M-x customise-face that means you have to press SPC SPC and then type in customise-face .
  • , is the mode leader, so when something is referenced as SPC m <something> you can simply use , <something>

Searching

  • SPC p p - Show projects you have opened previously
  • SPC p f - Find file in project
  • SPC s s - Swoop search (search in file) (you can also do the usual vim /)
  • SPC f f - Find file (fuzzy search)
  • SPC f r - Find/show recent files
  • SPC / - Find pattern (text) in open file (shortcut for SPC s p)
  • SPC * - Same as SPC / but searches what’s under the cursor
  • If you ned to search a term exactly, escape the space, e.g.: SPC / see\ the\ posts
  • SPC s a p find pattern (text) in project

Windows

  • SPC w s to split window SPC w v to split vertically
  • SPC w d to delete/close window (or Command W in OS X)

Buffers

  • SPC b b to list buffers
  • SPC TAB to go to last buffer

NeoTree

  • SPC f t open NeoTree
  • SPC 0 to select NeoTree window
  • SPC 1 to select first (other) window

Shells

  • SPC ' open shell (opens in the directory of the file you’re in)
  • SPC p ' open shell in root of project

Commenting/uncommenting

  • gcc or SPC cl comment/uncomment line
  • gc3j to comment an additional 3 lines down (end with k for up)
  • v highlight code then gc

Spacemacs Tutorials

Spacemacs Blog Posts

Spacemacs Themes

SpaceMacs Gitter Chat

https://gitter.im/syl20bnr/spacemacs - they are very active and helpful in their channel so definitely pay them a visit if you need help

Troubleshooting

If you get any warnings on startup, try SPC b b for buffers and look in ‘messages’.


Alchemist Elixir basic usage

Alchemist docs

Showing Posts 1 to 10

AstonJ

AstonJ OP

Just found this blog post, which looks like it contains some really good info (anyone feel anything is missing from it?)

And the Emacs Alchemist Cheat Sheet:

kblake

kblake

AstonJ

AstonJ OP

That looks really helpful - thanks!

Is it possible to get Neotree to always open on the right hand side? With Vim we can add this to .vimrc let g:NERDTreeWinPos = "right"

rubytree

rubytree

You asked about screen splitting in editors topic. You not only can manage windows like in Vim (hit spc w instead of ctrl+w, i.e. spc w v to split vertically) but there is awesome golden-ratio mode ( spc t g to toggle) where windows are resized using golden ratio and the largest is your current window.

By the way. No one mentioned magit which is the best git client ever!

kblake

kblake

@AstonJ I believe there is a way to do it. I don’t know specifically though. See: Customize neotree placement · Issue #87 · jaypei/emacs-neotree · GitHub

NobbZ

NobbZ

By the way. No one mentioned magit https://github.com/magit/magit which
is the best git client ever!

Best git client ever is git from command-line. I have not found any git
integration for any IDE or editor that’s that flexible as plain old git
executable.

AstonJ

AstonJ OP

Thanks all - I’m sure there’ll be a way, though (and I’ve only literally spent 5 minutes with it) but I may not even use it like I use Vim… already getting a different vibe - which I quite like :003:

From what I’ve seen so far it’s got a really, really nice feel. Will report back once I’ve had a good play tho. Definitely encourage everyone else to check it out as well. I love that hitting the space bar gives you a list of commands available - such a great idea!

rubytree

rubytree

It took me 2 days to be fully productive in spacemacs after almost 10 years in Vim. Give it a try it is perfect match - finally best operating system got its good text editor.

sandeshsoni

sandeshsoni

Here’s a tip from me:

user_allex = some_function_to_name "allex ocean"

In this example, to change the word allex ocean you can place a cursor anywhere in the word and hit ca" (change around ") and then just type the new text.

similarly we have

  • caw (change around word)
  • daw (delete around word)
  • cap (change around paragraph)
riverrun

riverrun

Similarly, you have the ‘i’ (inner) variants:

  • ciw (change within word)
  • cit (change within tags)
  • cib (change within parentheses)
  • ciB (change within curly brackets)
  • ci] (change within brackets)

I also use ‘ct’ (change until a character) and ‘cf’ (change until and including a character) a lot (these only work for characters on the same line).
All these commands are available on Vim as well.

Where Next? Top

Trending in Wikis Top

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews