Liking cljdoc? Tell your friends :D

Usage

Prerequisites

cider-nrepl supports only Clojure(Script) 1.10+ and Java 8+.

Leiningen users will need to have version 2.8.3 or newer installed.

Via Leiningen

Use the convenient plugin for defaults, either in your project’s project.clj file or in the :user profile in ~/.lein/profiles.clj.

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

A minimal profiles.clj for CIDER would be:

{:user {:plugins [[cider/cider-nrepl "0.50.0"]]}}

Or (if you know what you’re doing) add cider-nrepl to your :dev :dependencies vector plus specific middleware to :nrepl-middleware under :repl-options.

:dependencies [[cider/cider-nrepl "0.50.0"]]
:repl-options {:nrepl-middleware
                 [cider.nrepl/wrap-apropos
                  cider.nrepl/wrap-classpath
                  cider.nrepl/wrap-clojuredocs
                  cider.nrepl/wrap-complete
                  cider.nrepl/wrap-debug
                  cider.nrepl/wrap-format
                  cider.nrepl/wrap-info
                  cider.nrepl/wrap-inspect
                  cider.nrepl/wrap-log
                  cider.nrepl/wrap-macroexpand
                  cider.nrepl/wrap-ns
                  cider.nrepl/wrap-spec
                  cider.nrepl/wrap-profile
                  cider.nrepl/wrap-refresh
                  cider.nrepl/wrap-reload
                  cider.nrepl/wrap-resource
                  cider.nrepl/wrap-stacktrace
                  cider.nrepl/wrap-test
                  cider.nrepl/wrap-trace
                  cider.nrepl/wrap-out
                  cider.nrepl/wrap-undef
                  cider.nrepl/wrap-version
                  cider.nrepl/wrap-xref]}

Via clj

You can easily boot an nREPL server with the CIDER middleware loaded with the following "magic" incantation:

clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.50.0"} }}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"

There are also two convenient aliases you can employ:

{...
 :aliases
 {:cider-clj {:extra-deps {org.clojure/clojure {:mvn/version "1.10.3"}
                           cider/cider-nrepl {:mvn/version "0.50.0"}}
              :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}

  :cider-cljs {:extra-deps {org.clojure/clojure {:mvn/version "1.10.3"}
                            org.clojure/clojurescript {:mvn/version "1.10.339"}
                            cider/cider-nrepl {:mvn/version "0.50.0"}
                            cider/piggieback {:mvn/version "0.5.2"}}
               :main-opts ["-m" "nrepl.cmdline" "--middleware"
                           "[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}}

Which then allow you to simply run:

clj -M:cider-clj

Via embedding nREPL in your application

If you’re embedding nREPL in your application you’ll have to start the server with CIDER’s own nREPL handler.

(ns my-app
  (:require [nrepl.server :as nrepl-server]
            [cider.nrepl :refer (cider-nrepl-handler)]))

(defn -main []
  (nrepl-server/start-server :port 7888 :handler cider-nrepl-handler))

There’s nothing magical about the cider-nrepl-handler - all it does is to add all middleware defined in cider-nrepl to nREPL’s default handler. That’s how CIDER’s nREPL handler is created:

(def cider-middleware
  '[cider.nrepl/wrap-apropos
    cider.nrepl/wrap-classpath
    cider.nrepl/wrap-clojuredocs
    cider.nrepl/wrap-complete
    cider.nrepl/wrap-content-type
    cider.nrepl/wrap-debug
    cider.nrepl/wrap-enlighten
    cider.nrepl/wrap-format
    cider.nrepl/wrap-info
    cider.nrepl/wrap-inspect
    cider.nrepl/wrap-log
    cider.nrepl/wrap-macroexpand
    cider.nrepl/wrap-ns
    cider.nrepl/wrap-out
    cider.nrepl/wrap-slurp
    cider.nrepl/wrap-profile
    cider.nrepl/wrap-refresh
    cider.nrepl/wrap-reload
    cider.nrepl/wrap-resource
    cider.nrepl/wrap-spec
    cider.nrepl/wrap-stacktrace
    cider.nrepl/wrap-test
    cider.nrepl/wrap-trace
    cider.nrepl/wrap-tracker
    cider.nrepl/wrap-undef
    cider.nrepl/wrap-version
    cider.nrepl/wrap-xref])

(def cider-nrepl-handler
  "CIDER's nREPL handler."
  (apply nrepl-server/default-handler (map resolve-or-fail cider-middleware)))
You can build your own custom nREPL handler with the middleware you need by adjusting the code above.

With JBoss AS/JBoss EAP/WildFly

Using the advanced features of the info middleware with one of the JBoss application servers requires a tweak, since JBoss modules prevent modifications to AppClassLoader (usually the highest modifiable classloader) from being seen by application code. To work around this, run the following code from within your application to mark that classloader as unmodifiable, and cause the lower level clojure.lang.DynamicClassLoader to be used instead. This code must execute prior to loading the cider-nrepl middleware. Note that this is only if you are deploying a standard WAR file to the application server directly. If you are using Immutant (1.x or 2.x), you won’t need to do this.

(require '[dynapath.dynamic-classpath :as cp])

(extend sun.misc.Launcher$AppClassLoader
  cp/DynamicClasspath
  (assoc cp/base-readable-addable-classpath
    :classpath-urls #(seq (.getURLs %))
    :can-add? (constantly false)))

Can you improve this documentation? These fine people already did:
Bozhidar Batsov, vemv, Oleksandr Yakushev, p4v4n, Filipe Silva, Jordan Biserkov & Roman Scherer
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close