Customizing Spacemacs

This is the Chapter 3 of a Series of Blog Posts about Spacemacs, feel free to check out the starting point on Vim and Emacs: Spacemacs! or use the following links to go to the previous or the next chapter in the series:

< < < Windows, Buffers and Quitting • Using GIT in Spacemacs > > >

Customizing Spacemacs is really easy. You just need to know which lever to pull. (by GregoryButler)

The .spacemacs file

This is where most of our changes will be made and most of them are pretty straightforward.

The .spacemacs is placed right within your home directory, in my case, at /Users/jsoifer/.spacemacs but there is a shortcut to get straight access to it within Spacemacs: SPC f e d , a super convenient mnemonic for “Spacemacs, File Edit Damn!”

Easy Customizations

This file is loaded with things that we can easily change and customize to suit our needs.

It pays to read through this entire file at least once, even if just skimming through it. You will see that many interesting options can be changed just by switching a null to 't.

A few examples:

  • dotspacemacs-startup-banner 'nil
  • dotspacemacs-folding-method 'evil
  • dotspacemacs-smart-closing-parenthesis 'all

Applying Changes

After we’re done, it is actually pretty simple to reload the Spacemacs configuration file and check the changes:

  1. Save it SPC f s.
  2. Reload it SPC f e R (capital Rand yes, it makes a difference).

A Few Things I Wished Someone Told Me™

Most of the these things are mentioned in the Official Documentation, as usual. But it is rather “too complete”: some people (like me) may end up lost in a sea of information. Don’t be like me.

“Developer proudly shares her .spacemacs on Github Gists”. Oil on Canvas. Circa 1870. (by Léon Bazille Perrault)

1. Layers and Packages

“Layers help collect related packages together to provide features. For example, the python layer provides auto-completion, syntax checking, and REPL support for python files. (…). To install all the python features the user has just to add thepython layer to their dotfile.”

Information Straight from the Docs™!

Just try to remember this: most common functionalities, like the support for a lot of Programming Languages and Frameworks (like Elixir, JavaScript, Ruby and many others) is provided by Layers: they glue and set-up different packages together.

“This approach helps keep configuration organized and reduces overhead for the user by keeping them from having to think about what packages to install.”

2. The simplest example

I’m a happy Mac OS user, so the very first Layer I needed to install was the osx layer. Inside of the dotspacemacs-configuration-layers '( ... ) section, I added the osx layer, saved the change and SPC f e R, like so:

It doesn’t get any easier than this.

3. A more complex example

Some layers also allow variable setting within their declaration, like the Wakatime layer. This is also happening inside the dotspacemacs-configuration-layers section:

Obviously not my real API Key. C’mon sis.

4. Adding Git Support

Adding git and the Magit layer is also really simple. Just go inside your .spacemacs dotspacemacs-configuration-layers and add git to it.

We will be using it in the next section, so this is kinda important.

What about everything else?

Most other configurations should go into the (defun dotspacemacs/user-config () ) section of the .spacemacs file.

This is where I’m turning on the Global Company Mode for autocompletion and also the Indentation Guide in all Major Modes as well as some Web Mode customizations (JavaScript tab size, AirBnB Linting Rules and etc.).

It’s a mess. I know. I should be organizing it soon.

On the next article I’ll be explaining how to use Git! Stay tuned.

Want to stay up to date? I’m also on GitHub and Twitter (how unexpected!).