Additional Packages

There are many additional Emacs packages that can enhance your Clojure programming experience. The majority of the minor modes listed here should be enabled for both cider-repl-mode and clojure-mode for optimal effects.

The packages listed here belong to three categories:

  • CIDER extensions

  • Generic Emacs packages useful for Clojure programming

  • CIDER alternatives

CIDER Extensions

Make sure that the version of any extension you’ve installed is compatible with your CIDER version.

CIDER extensions typically are Emacs packages that built on top of CIDER’s Emacs Lisp API. Some of them ship with extra nREPL middleware as well (e.g. clj-refactor). Typically packages that rely on middleware would hook into CIDER’s middleware injection functionality and inject their own functionality automatically as well.

Keep in mind that currently there are no "official" CIDER extensions and the packages on the list are not maintained by CIDER’s Core Team. Their quality and level of maintenance may vary significantly.

clj-refactor

clj-refactor builds on top of clojure-mode and CIDER and adds a ton of extra functionality (e.g. the ability to thread/unthread expression, find and replace usages, introduce let bindings, extract function and so on).

A full list of features is available here.

We hope to incorporate some of its features into clojure-mode and CIDER themselves down the road.

emidje

Emidje is a test runner, report viewer and formatting tool for Midje within Emacs.

Emidje extends CIDER to provide support for Midje tests in a similar fashion as cider-test.el does for clojure.test tests. In fact, most of Emidje’s functionalities were strongly inspired by cider-test.el features.

kaocha-runner

kaocha-runner provides Kaocha integration for Emacs.

helm-cider

helm-cider provides a Helm interface for certain CIDER commands (e.g. cider-apropos).

cider-hydra

cider-hydra provides a nice way to navigate groups of related CIDER commands.

You can think of it as a fancier which-key.

flycheck-clj-kondo

flycheck-clj-kondo is a Flycheck checker for Clojure that provides instant linting of clojure code as you type, via clj-kondo.

clj-kondo is a great way of preventing yourself from writing buggy code.

squiggly-clojure

squiggly-clojure is a Flycheck checker for Clojure, using tools like eastwood, core.typed and kibit.

sayid

sayid is a powerful alternative of CIDER’s built-in basic tracing functionality.

Generic Emacs Extensions

Most packages in the following list are standard Emacs minor modes that work with most major modes, but are especially handy for Lisp-like languages like Clojure.

subword-mode

Enabling CamelCase support for editing commands(like forward-word, backward-word, etc) in the REPL is quite useful since we often have to deal with Java class and method names. The built-in Emacs minor mode subword-mode provides such functionality:

(add-hook 'cider-repl-mode-hook #'subword-mode)

Paredit

The use of paredit when editing Clojure (or any other Lisp) code is highly recommended. You’re probably using it already in your clojure-mode buffers (if you’re not you probably should). You might also want to enable paredit in the REPL buffer as well:

(add-hook 'cider-repl-mode-hook #'paredit-mode)

Smartparens

smartparens is an excellent alternative to paredit. Many Clojure hackers have adopted it recently and you might want to give it a try as well. To enable smartparens in the REPL buffer use the following code:

(add-hook 'cider-repl-mode-hook #'smartparens-strict-mode)

rainbow-delimiters

RainbowDelimiters is a minor mode which highlights parentheses, brackets, and braces according to their depth. Each successive level is highlighted in a different color. This makes it easy to spot matching delimiters, orient yourself in the code, and tell which statements are at a given depth. Assuming you’ve already installed RainbowDelimiters you can enable it in the REPL like this:

(add-hook 'cider-repl-mode-hook #'rainbow-delimiters-mode)

eval-sexp-fu

eval-sexp-fu provides some visual feedback when evaluating expressions. cider-eval-sexp-fu provides CIDER integration for eval-sexp-fu.

(require 'cider-eval-sexp-fu)

Alternatives

It’s generally a bad idea to mix Clojure programming environments, as all of those tend to modify clojure-mode 's keymap while active. Run only one environment at a time unless you really know what you’re doing.

This section enumerates other Emacs packages that provide a Clojure programming environment for Emacs.

Inf-clojure

This package provides basic interaction with a Clojure subprocess (REPL). It’s based on ideas from the popular inferior-lisp package.

inf-clojure has two components - a nice Clojure REPL with auto-completion and a minor mode (inf-clojure-minor-mode), which extends clojure-mode with commands to evaluate forms directly in the REPL.

It’s basically a simple alternative of CIDER, which provides a subset of CIDER’s functionality.