Setting up Clojure and Emacs using Leiningen and nREPL

A quick and dirty guide to setting up Clojure and Emacs using Leiningen and nREPL.  Current as of 2013-03-18.

Per Machine

Install leiningen 2:

$ curl https://raw.github.com/technomancy/leiningen/preview/bin/lein -o ~/bin/lein
$ chmod +x ~/bin/lein
$ lein self-install

Get clojure-mode:

$ cd ~/git/
$ git clone git://github.com/technomancy/clojure-mode.git

Get nrepl-mode:

$ cd ~/git/
$ git clone git://github.com/kingtim/nrepl.el.git

Update your .emacs:

;; Clojure
(add-to-list 'load-path "~/git/clojure-mode")
(add-to-list 'load-path "~/git/nrepl.el")
(require 'clojure-mode)
(require 'nrepl)


Per Project

Create a project:

$ cd ~/src/
$ lein new {project}
$ cd {project}


Per Session

Run emacs:

emacs src/{project}/core.clj
M-x nrepl-jack-in
; Wait for emacs to invoke and connect to the clojure nREPL


Read more about the emacs nrepl keybindings.

Enjoy!









Comments