Editors for Clojure developmentλ︎
The best editor to use for learning Clojure is the editor already familiar with (or want to learn).
Use SublimeText & ClojureSublimed if unsure where to start as it will be the simplest tool to use.
Clojure editor featuresλ︎
An ideal Clojure editor includes the these core features
- running / connecting to a REPL process
- evaluation results inline or in a repl window (fast feedback on what the code does)
- syntax highlighting (including highlight of matching parens)
- structural editing to ensure parens are balanced when writing and refactor code
- data inspector to visualise large and nested data, or connection to data inpector tools
Clojure aware editorsλ︎
Emacs (Spacemacs, Doom, Prelude), Neovim (Conjure) and VSCode (Calva) are the most common open source Editors for Clojure and ClojureScript development.
SublimeText and IntelliJ are commercial editors (with limited free editions) which also provide Clojure support
Emacs is a very powerful editor with thousands of packages enabling a person to do almost any digital task concievable. Emacs is highly extensible via the ELisp programming language used to write configuration and the numerous Emacs packages. Native Compilation of Emacs packages dramatically speeds up many common tasks.
Emacs uses CIDER and Clojure LSP for a feature rich clojure development experience.
Use one of the popular community configurations for Emacs or visit the CIDER documentation to learn how to add Clojure support to Emacs.
Spacemacs is a community configuration bringing Emacs features and Vim style editing together. Spacemacs uses a mnemonic menu system that makes it easy to learn and provides detailed documentation for configuring and using Emacs.
Practicalli Spacemacs provides a guide to Clojure development, vim-style editing, documenting with org-mode, Git version control with Magit, Issues & Pull Requests with Forge and dozens of other features.
Practicalli Spacemacs Config contains a customised configuration for Clojure development and supporting tools.
The Practicalli configuration should replace the ~/.spacemacs
file if it exists
Spacemacs install guide - Practicalli Spacemacs
Emacs Prelude is an easy to use Emacs configuration for Emacs newcomers and lots of additional power for Emacs power users, from the author of CIDER - the definitive Clojure IDE for Emacs.
Prelude uses the traditional chorded key bindings to drive Emacs, e.g. Ctrl+c Ctrl+c to evaluate the current top-level form.
Doom Emacs is a community configuration for Emacs that provides a minimalistic configuration that is readily customisable. Doom Emacs is most suited to those coming from Vim and have a strong experience for multi-modal editing.
Practicalli Doom Emacs Config contains a customised configuration for Clojure development and supporting tools.
~/.config/doom/
directory created by the doom install
command.
Emacs 29 is recommended as it includes native compilation support and optomised JSON support which is valuable for Language Server Protocol servers.
Emacs is available for Linux, MacOSX and Windows.
apt-cache show emacs
to check available versions of Emacs in the Ubuntu package manager. If version 28 is available, install Emacs using the Ubuntu package manager.
Additional versions of Emacs are available via the Ubuntu Emacs Team Personal Package Archive.
sudo apt install emacs-snapshot
package to use the latest nightly build of Emacs, although be aware that some things may break.
Build Emacs from source
Building Emacs from source code has a few steps to ensure dependencies are present.
Building Emacs allows customisation of features included in Emacs, e.g. JSON support, XWidgets or native compilatin of elisp to enhance the performance of Emacs.
Emacs will take 15-30 minutes to compile, then the binary created can be installed.
Emacs Plus from Homebrew provides many options, including native compilation and Spacemacs Icon for application launchers.
Emacs.app is installed to: /usr/local/opt/emacs-plus@28
Optionally run Emacs plus as a service
Run emacs
Get a hot cup of something as Emacs native compilation compiles all the things.
Download Emacs-28.2 from the GNU repository and extract the zip file to %AppData%/local/Programs/emacs
.
Alternatively, if you are using the Chocolatey package manager then install Emacs version 28
Add the Emacs directory to the PATH
variable in your user account environment variables.
To start Emacs run the command runemacs.exe
. You can also pin this to the start menu or task bar.
Access to common Unix tools
Command line tools, such as diff
, are used by Emacs. To have these command line tools available in Windows, install Emacs as above but then run emacs from a Unix shell such as GitBash.
Once Emacs is installed, add the cider package for essential Clojure support.
Neovim is a hyper-extensible text editor that runs in a terminal, configured with the Lua programming language. Configuration can also be written in Fennel (a lisp dialect), using nfnl to generate Lua code.
Neovim is based on multi-model editing (e.g. normal, insert, visual editing states) providing a highly effective tool for writing code, configuration and documentation.
Neovim includes Treesitter which understands the syntax of a great many programming and configuration languages, which can be coupled with analysist from Language Sever Protocol (LSP) servers to provide live feedback on code quality.
Conjure provides Clojure interactive (REPL) development, supporting Clojure CLI, Leiningen and Babashka projects (as well as several other Lisp dialects and interesting languages)
Try the Conjure interactive :ConjureSchool
tutorial which only requires a recent version of neovim
:q
to quit the tutorial.
Practicalli Neovim - Astro install
AstroNvim community configuration for Neovim provides an engaging UI, using Lazy plugin manger and Mason to manage LSP servers, format & lint tools.
Practicalli Astro provides a user configuration for Astronvim, including Conjure, parinfer, LSP server and treesitter parser for Clojure development.
Practicalli Neovim provides an install and user guide for Neovim and Conjure for Clojure development, folloiwng a REPL driven workflow.
SpaceVim is a fully featured vim experience that includes a minimal Clojure development environment based around vim-fireplace
Follow the Quick Start Guide to install SpaceVim
Add the Clojure layer to the SpaceVim custom configuration file
Interactive Clojure Environment for Vim8/Neovim, aimed at the more experienced Vim/Neovim user.
vim-iced uses vim-sexp for structural editing
vim-plug is required to install the vim-iced packages.
VS Code is a freely available editor build on open source and available for Linux, MacOS and Microsoft Windows.
VS Code has a large marketplace of extensions, proiding additional tools for a complete development environment.
Calva is the most commonly used extension for Clojure support and aims to provide similar features to Emacs Cider (and uses some of the same Clojure libraries).
Clojure CLI User Aliases not directly supported
Calva does not support Clojure CLI user aliases directly (only project deps.edn). A JSON mapping must be added to the Calva configuration for each user alias (duplicating configuration)
Practicalli recommends starting the Clojure REPL in a terminal and specifying the required Clojure CLI user aliases, using Calva connect once the REPL has started.
VSpaceCode provides a mnemonic menu to drive VS Code by keyboard alone, vim editing and rich Git client (edamagit). VSpaceCode extension also provides key bindings for common Calva commands. Users experienced with Neovim and Emacs (Spacemacs / Doom) will find this extension makes VS Code easiter to use than vanilla VS Code or VS Code with an Neovim backend.
Clover provides a mininal, highly customisable environment using Socket REPL.
The Calva extension adds Clojure REPL support to VS Code editor, including Clojure LSP, formatting, structural editing and many other features.
Calva is under active development and the #calva channel on the Clojurians Slack community can be supportive.
Calva Getting Started Guide Calva - VS Code Marketplace
VSpaceCode is a Spacemacs-like community configuration for Microsoft VS Code. Drive VS Code entirely from the keyboard, using easy to remember mnemonic keys for all commands and full vim-stile editing tools.
Calva extension must be added as it is not part of VSpaceCode, although Calva commands are included in the VSpaceCode mneomoic menu when a Clojure file is open.
Edamagit is a sophisticated text based Git client (like magit for Emacs) is also included in the VSpacemacs extension.
Practicalli VSpaceCode install guide Practicalli VSpaceCode user guide
Clover is a Socket REPL based development tool for Clojure with some ClojureScript support (not including Figwheel).
Clojure GitLab repository includes usage details.
SublimeText 4 is a lightweight and feature rich text editor, especially of interest to those that like a simple and uncluttered UI. SublimeText is a commercial project although has free trial version available (check conditions of use).
Clojure-Sublimed provides Clojure support for SublimeText 4, with support for Clojure & Edn syntax, code formatting and an nREPL client to connect to a Clojure REPL process.
Tutkain is an Sublime 4 package that supports Clojure development (self-described as alpha software).
Build configuration to start a REPL
Clojure Sublime connects to a REPL via an nREPL server. Run a terminal REPL using Clojure CLI, Leinginen (lein repl
) or Shadow-cljs (shadow-cljs watch app
)
Alternatively, configure Clojure Sublimed to run a REPL process by creating a new build system via Tools » Build System » New Build System. The following example starts a Clojure CLI REPL with nREPL server and assumes Java and Clojure CLI are installed.
Run a REPL process via Tools » Build With… and connect to the REPL using the command Clojure Sublimed: ConnectSublimeText install Clojure-Sublimed install SublimeText Documentation
Pulsar Community-led Hyper-Hackable Editor is a very new project to create a community version of the Atom editor from GitHub.
Chlorine plugin provides a Clojure and ClojureScript development environment using Socket-REPL integration
Pulsar Community-led Hyper-Hackable Editor Pulsar Chlorine plugin
Atom not actively developed
Atom will be archived on December 15 2022 with no further updates from GitHub team
Consider using VSCode with Clover or Calva plugin or help support the evolution of the Pulsar project
Cursive may be an appropriate choice for people from a Java background who are already familiar with IntelliJ. Cursive will run static analysis of Clojure code when opening a Clojure project, as IntelliJ does with other languages.
Follow the Cursive user guide to configure IntelliJ and install Cursive.
Requires license for commercial development
There is a free license when development is not for commercial projects, however, a license must be purchased for each developer working on a commercial project.