Enhancing the Clojure experience
Adding the clojure layer provides a Clojure development experience based on CIDER
We can make the development experience even better by adding a few more layers and some optional packages for the clojure layer:
Layers are defined in the
dotspacemacs-configuration-layers section of the
~/.spacemacs configuration file.
||to complete names of functions, symbols, etc.|
||CIDER with clj-refactor and sayid debugger|
||git version control with Magit|
||writing project descriptions in README.md and other markdown files|
||write project documentation, organise tasks withorg-mode|
||spell checking words as you type using Fly Spell|
||general version control features, eg. diff margins|
Edit .spacemacs and add layers
.spacemacs file via
SPC f e d (
M-m f e d Emacs state)
/ and start typing
configuration-layers to search for the
RTN confirms the search text and
n jumps to the next occurance,
N jumps to the previous occurrence.
Add the following layers to
dotspacemacs-configuration-layers '( (auto-completion :variables auto-completion-enable-help-tooltip t auto-completion-enable-snippets-in-popup t auto-completion-enable-sort-by-usage t) (clojure :variables clojure-enable-clj-refactor t) emacs-lisp (git :variables git-magit-status-fullscreen t git-enable-github-support t git-gutter-use-fringe t) helm markdown treemacs org spell-checking syntax-checking (version-control :variables version-control-diff-tool 'diff-hl version-control-global-margin t) )
Configuring layers with :variables
:variables directive on layers allows you to add features from named packages, e.g.
clojure-enable-clj-refactor to include
clj-refactor Clojure projects.
:variables also allow you to configure options for layers, e.g.
git-gutter-use-fringe to display changed lines in your working file in the fringe (margin) of the current buffer.
I have not included the sayid debugger in this enhanced setup for Clojure as I find the
, d b, to be most useful.
If you wish use extensive debugging for the whole project, then enable sayid by adding the variable
clojure-enable-sayid. So your layer definition for Clojure would look like:
(clojure :variables clojure-enable-sayid t clojure-enable-clj-refactor t)
Reload Configuration or Restart Emacs
You can either reload the
~/.spacemacs configuration using
SPC f e R or quit Emacs
C-x C-c and restart Emacs again.
I recommend restarting Emacs to ensure all the new packages are installed and configured.
SPC h SPC (or
M-m f e h in Emacs state) displays a list of all layers available in Spacemacs. Type the layer name or scroll down (
C-j) to a layer name and press
TAB to preview the documentation for that layer or
RTN to open the docs for that layer in a buffer.
Create your own layers with
SPC SPC configuration-layer/create-layer. See the Spacemacs docs and Configuring Spacemacs, a tutorial for more information.
Spacemacs Clojure configuration example
Mnemonic keybindings and menus
The Spacemacs menu system use a nemonic system for organising its menus and commands. So to access a menu of file related commands, you press
SPC f and for a menu of buffer commands you would use
The keybindings to open the file of the emacs dotfile (.spacemacs) are therefore:
SPC f e d