= Editors
Alex Miller
2022-05-19
:type: guides
:toc: macro
:icons: font

ifdef::env-github,env-browser[:outfilesuffix: .adoc]

toc::[]

Clojure is an interactive language and you will only get the best Clojure experience by using an editor that supports code evaluation (via a connected REPL) and structural editing (manipulating code forms as if they are data, not text). Fortunately, there are many excellent Clojure editors that provide these features and many other programmer conveniences.

Note that many of the editors described below are in active development. Links and resources here might become stale. We welcome https://ask.clojure.org[questions] and https://github.com/clojure/clojure-site/issues[issues]!

== Emacs - most popular, most customizable

https://www.gnu.org/software/emacs/[Emacs] is one of the oldest editors still in active use. As a platform extensible in its own variant of Lisp, options exist for almost anything you might want to do. As you may expect, great extensibility means configuring this tool to your liking can be a job in itself and for some Emacs is more of a lifestyle than an editor. That said, there are friendly starting points just for Clojure developers and you choose the rate at which you absorb the Emacs ecosystem.

The main Emacs modes to be aware of are:

* https://github.com/clojure-emacs/clojure-mode[clojure-mode], an Emacs major mode that provides font-lock (syntax highlighting), indentation, navigation and refactoring support for Clojure(Script)
* https://cider.mx/[CIDER] extends Emacs with support for interactive programming in Clojure via cider-mode, an Emacs minor-mode that complements clojure-mode to provide interactive support.
* https://github.com/clojure-emacs/inf-clojure[inf-clojure] - provides basic interaction with a Clojure subprocess (REPL), based on ideas from the popular inferior-lisp package

Some places to start:

* https://www.gnu.org/software/emacs/download.html[GNU Emacs - download and install] - the official GNU Emacs page
* https://practical.li/spacemacs/install-spacemacs/[Practicalli guide to Spacemacs], a community driven Emacs configuration for Clojure - includes clojure-mode and CIDER
* https://prelude.emacsredux.com/en/latest/[Prelude] - an Emacs configuration for Emacs beginners, not specific to Clojure, but includes Clojure support (clojure-mode, CIDER)
* https://aquamacs.org/[Aquamacs] - Aquamacs is Emacs designed for the Mac native user in mind and is sufficient for a minimalist Clojure environment when paired with inf-clojure mode (recommended: https://github.com/cognitect-labs/aquamacs-support[aquamacs-support])

== IntelliJ - Clojure with a Java tilt

https://www.jetbrains.com/idea/[IntelliJ IDEA] is one of the premiere "modern" IDEs with support for a wide variety of languages and tools. IntelliJ made its name as a sophisticated Java editor, leveraging a static analysis platform to provide great explorability and refactoring for large Java codebases. The IntelliJ IDEA Community Edition for JVM development is available as a https://www.jetbrains.com/idea/download/#section=mac[free download].

Two important plugins are available to enable Clojure development on IntelliJ:

* https://cursive-ide.com/[Cursive] - a full featured Clojure development environment
* https://plugins.jetbrains.com/plugin/18108-clojure-extras/[clojure-extras] - integrates extras like inline evaluation results and linting via https://github.com/clj-kondo/clj-kondo[clj-kondo]

Cursive is a good fit if you are already familiar with Java or expect to work with mixed Clojure/Java projects.

== VS Code - rapidly evolving, beginner friendly

https://code.visualstudio.com/[Visual Studio Code] is rapidly growing in use for a variety of languages, and Clojure is no exception. 

The https://calva.io/[Calva] environment for interactive Clojure development uses a mix of static and dynamic analysis to provide a wide range of language support. Additionally, Calva has made extra efforts to be approachable to beginners with their https://calva.io/get-started-with-clojure/[Getting Started] experience, which is a zero-install version that runs in the browser. 

== Vim - highly efficient text editing

https://www.vim.org/[Vim] (or vi) is also an editor with a long history, known for its ability to edit text quickly and efficiently.  It has become the de-facto replacement for vi, the original Unix visual editor on which it was based.

Its unique, powerful UI is popular enough that most other editors mentioned above include vi-modes that reproduce Vim's core UI functionality.

https://neovim.io/[Neovim] is a fork of Vim.  While it maintains a high degree of compatibility, there are some significant differences between the two editors.

Both Vim and Neovim are highly extensible and a vast array of plugins are available for them.  Most, but not all, plugins will work with both editors.

The following plugins provide Clojure support for both Vim and Neovim:

* https://github.com/tpope/vim-fireplace[Fireplace] - Clojure support and REPL integration
* https://liquidz.github.io/vim-iced/[vim-iced] - CIDER inspired
* https://github.com/guns/vim-slamhound[vim-slamhound] - Automated namespace rewriting

The following plugins only provide Clojure support to Neovim:

* https://github.com/Olical/conjure[Conjure] - focus on interactive development

In addition to the Clojure plugins, it is also worth extending Vim to improve the editing of s-expressions. The plugins below can be used with both Vim and Neovim:

* https://github.com/guns/vim-sexp[vim-sexp] - precision editing of S-expressions
* https://github.com/tpope/vim-sexp-mappings-for-regular-people[vim-sexp-mappings-for-regular-people] - alternative keybindings that some users may prefer
* https://github.com/tpope/vim-surround[vim-surround] - makes it easier to wrap expressions in brackets, quotes, and other tokens.

There are also numerous plugins that provide color-matching of parentheses.

== Others

Other environments exist but are less active and/or less used. See the <<xref/../../../community/tools#,Tools>> page for other ideas.
