Setup Emacs for Clojure development.
Emacs is the most well-loved Clojure editor. One of the reasons behind this is its LISPy roots.
Depending on your setup, there are multiple ways to install these packages. This guide assumes that you have straight.el or use-package installed. If you'd like to install one of these, we recommend Straight.el, mainly because it lets you fetch packages directly from Github. You can check out my personal .emacs.d if you'd like to review my setup.
Once you have
use-package in place (via Straight or use-package), we can install the required packages. You will probably need to add this configuration to the
init.el file. To get Clojure working with Emacs, we need the following packages:
;; First install the package, then install the checker as soon as `clojure-mode' is loaded
(add-hook 'clojure-mode-hook 'cider-mode)
(add-hook 'clojurescript-mode-hook 'cider-mode)
(add-hook 'clojurec-mode-hook 'cider-mode)
(add-hook 'cider-repl-mode-hook 'cider-mode))
(setq cider-repl-display-help-banner nil)
(setq cider-auto-mode nil))
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'clojure-mode-hook 'paredit-mode)
(add-hook 'clojurescript-mode-hook 'paredit-mode)
(add-hook 'clojurec-mode-hook 'paredit-mode)
(add-hook 'cider-repl-mode-hook 'paredit-mode)))
This setup is a good starting point. It's not a standard, in fact far from it. We suggest that you start with this and keep tweaking until it suits you. If you discover something that works well for you, let me know too!