Skip to content

Quick start: Clojure

Mikkel Gravgaard edited this page Sep 8, 2021 · 18 revisions

Clojure is a robust, practical, and fast programming language with a set of useful features that together form a simple, coherent, and powerful tool.

Conjure has deep support for Clojure either in the original JVM setting or JavaScript via ClojureScript. We’re focusing on regular JVM Clojure here, see other guides for specifics on ClojureScript since it has it’s own nuances.

Prerequisites

  1. Install the latest Neovim.

  2. Install the Conjure plugin.

  3. Install the Clojure CLI tools (my preference) or Leiningen.

  4. Get a project set up with the CLI tools or Leingingen.

Start your nREPL + CIDER middleware

You can skip this section by installing vim-jack-in and executing the appropriate command such as :Clj or :Lein. It’ll start an nREPL server with all of the appropriate middleware inside your Neovim instance, you can then connect to it as described in the final section.

With Clojure CLI

Configure your deps.edn like so to acquire the appropriate dependencies.

{:deps
 {org.clojure/clojure {:mvn/version "1.10.1"}
  nrepl/nrepl {:mvn/version "0.7.0"}
  cider/cider-nrepl {:mvn/version "0.25.2"}}}

Now start your nREPL server with the added CIDER middleware.

clj -m nrepl.cmdline \
    --middleware "[cider.nrepl/cider-middleware]" \
    --interactive

Alternatively, you can start the same thing without creating a deps.edn file with this.

clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.7.0"} cider/cider-nrepl {:mvn/version "0.25.2"}}}' \
    -m nrepl.cmdline \
    --middleware '["cider.nrepl/cider-middleware"]' \
    --interactive

With Leiningen

Simply add the CIDER plugin to your project.clj.

:plugins [[cider/cider-nrepl "0.24.0"]]

And start your REPL which will automatically start nREPL + CIDER.

lein repl

Start editing!

Now open any .clj or .cljc file and start evaluating! It will automatically connect to the correct host and port as you open a file providing the .nrepl-port was created when you started your REPL (this should be the case). If not, you can either create that file yourself or use :ConjureConnect [port] to get started.

If you’re unsure how to evaluate things with Conjure, please refer to :help conjure, :help conjure-client-clojure-nrepl and :ConjureSchool (an interactive tutorial).