This is part of oh-my-emacs.
This file contains some settings for Clojure programming language.
Package | Windows | Ubuntu/Debian/Mint | ArchLinux | Fedora | Mac OS X | Mandatory? |
---|---|---|---|---|---|---|
Leiningen | [web] | [web] | [web] | [web] | [web] | Yes |
Note:
- Leiningen for Clojure. I recommend you install leiningen from the official website to keep update with the lastest version.
Package | Status | Description |
---|---|---|
clojure-mode | Required | Major mode for Clojure. |
CIDER | Required | CIDER is a Clojure IDE and REPL for Emacs |
ac-cider | Required | Emacs auto-complete client for CIDER |
Clojure is a modern Lisp on top of JVM, it is a member of the Lisp family of languages. Clojure extends the code-as-data system beyond parenthesized lists (s-expressions) to vectors and maps.
Since Clojure is a Lisp dialect, it should work the SLIME way. Yeah, first comes swank-clojure, then CIDER[1]. The only thing you need to install is leiningen 2.x. I recommend you to install it manually, since not all package manager provides the latest version.
The general way to install lastest stable leiningen is:
wget -O /tmp/lein https://raw.github.com/technomancy/leiningen/stable/bin/lein
sudo mv /tmp/lein /usr/bin/lein
lein version
Or you can see leiningen’s wiki for upgrading details.
And to make leiningen works with emacs cider, you should make leiningen know
something about cider, here’s my $HOME/.lein/profiles.clj
:
{:user
{:plugins
[[cider/cider-nrepl "0.8.2"]]}
:repl-options
{:nrepl-middleware
[cider.nrepl.middleware.apropos/wrap-apropos
cider.nrepl.middleware.classpath/wrap-classpath
cider.nrepl.middleware.complete/wrap-complete
cider.nrepl.middleware.info/wrap-info
cider.nrepl.middleware.inspect/wrap-inspect
cider.nrepl.middleware.macroexpand/wrap-macroexpand
cider.nrepl.middleware.ns/wrap-ns
cider.nrepl.middleware.resource/wrap-resource
cider.nrepl.middleware.stacktrace/wrap-stacktrace
cider.nrepl.middleware.test/wrap-test
cider.nrepl.middleware.trace/wrap-trace
cider.nrepl.middleware.undef/wrap-undef]}}
Now, just open a clojure file, then cider-jack-in
, and you can program
Clojure the SLIME way. Here is an awesome live demo to demonstrate the Clojure
workflow.
It’s really really awesome, ah?
(ome-install 'clojure-mode)
(defun ome-cider-setup ()
(add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode)
(setq nrepl-hide-special-buffers t)
(setq cider-repl-tab-command 'indent-for-tab-command)
(setq cider-prefer-local-resources t)
(setq cider-repl-pop-to-buffer-on-connect nil)
(setq cider-repl-pop-to-buffer-on-connect nil)
(setq cider-popup-stacktraces nil)
(setq cider-repl-popup-stacktraces t)
(setq cider-auto-select-error-buffer t)
(setq nrepl-buffer-name-show-port t)
(setq cider-repl-display-in-current-window t)
(setq cider-repl-result-prefix ";; => ")
(setq cider-interactive-eval-result-prefix ";; => ")
(setq cider-repl-use-clojure-font-lock t)
(setq cider-test-show-report-on-success t)
(setq nrepl-hide-special-buffers t)
(setq nrepl-buffer-name-separator "-")
(setq nrepl-buffer-name-show-port t)
;; repl history
(setq cider-repl-wrap-history t))
(defun ome-ac-cider-setup ()
(add-hook 'cider-mode-hook 'ac-flyspell-workaround)
(add-hook 'cider-mode-hook 'ac-cider-setup)
(add-hook 'cider-repl-mode-hook 'ac-cider-setup)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'cider-repl-mode)))
(when (executable-find "lein")
(ome-install 'cider)
(ome-install 'ac-cider))
- The boot up speed of JVM is too slow, so we may need to refer to http://icylisper.github.io/jark/.
[1] CIDER was formerly known as and renamed from nrepl.el
.