= Configuration

In this section we'll briefly examine some common configuration
options related to ClojureScript. Configuration that is specific
to a particular REPL (e.g. `shadow-cljs`) is covered separately
in the individual REPL setup sections.

== Modifying the ClojureScript jack-in dependencies

Out-of-the-box, CIDER injects a single dependency into ClojureScript REPLs - namely `piggieback`.
If you'd like to inject more deps you'll have to modify the `cider-jack-in-cljs-dependencies`
variable. Here's an example:

[source,lisp]
----
;; let's add Weasel on jack-in
(cider-add-to-alist 'cider-jack-in-cljs-dependencies "weasel/weasel" "0.7.1")
----

IMPORTANT: Always use the fully qualified `group/artifact` (e.g. `re-frame/re-frame`) in these dependencies, since only Leiningen supports the bare `re-frame` syntax.

Typically, modifying this variable is not needed, as ClojureScript dependencies are declared
explicitly in your project configuration most of the time.

NOTE: Modifying this variable will affect all ClojureScript REPL types.

== Setting a Default ClojureScript REPL Type

If you frequently use the same ClojureScript REPL, you can set
`cider-default-cljs-repl` and CIDER will skip the prompt and use this
instead. For example, the following will make Node.js the default:

[source,lisp]
----
(setq cider-default-cljs-repl 'node)
----

== Defining Custom ClojureScript REPL Types

All supported ClojureScript REPLs are stored in
`cider-cljs-repl-types`. If you need to extend it, you should use
`cider-register-cljs-repl-type` in your Emacs configuration.

[source,lisp]
----
(cider-register-cljs-repl-type 'super-cljs "(do (...))" optional-requirements-function)
----

NOTE: If you're registering a self-hosted (native) ClojureScript REPL (e.g. `scittle`), the "upgrade" form should be `nil`.

You can also modify the known ClojureScript REPLs on a per-project basis using
`.dir-locals.el`:

[source,lisp]
----
;; replace the list of REPL types and set some default
((nil
  (cider-default-cljs-repl . super-cljs)
  (cider-cljs-repl-types . ((super-cljs "(do (foo) (bar))")))))
----

[source,lisp]
----
;; modify the list of known REPLs and set some default
((nil
  (eval . (cider-register-cljs-repl-type 'super-cljs "(do (foo) (bar))"))
  (cider-default-cljs-repl . super-cljs)))
----

For one-off REPLs you can also use the custom REPL init form like this:

[source,lisp]
----
;; modify the list of known REPLs and set some default
((nil
  (cider-custom-cljs-repl-init-form . "(do (foo) (bar))"
  (cider-default-cljs-repl . custom)))
----

If you already have a Clojure REPL running and want to add a
ClojureScript REPL, you can invoke
`cider-jack-in-sibling-clojurescript` to add it.

== Enhanced Completion

By default CIDER will enrich the ClojureScript completion results using
the https://github.com/rksm/clj-suitable[suitable] library. If case you run
into any `suitable`-related issues you can disable the enhanced completion like this:

[source,lisp]
----
(setq cider-enhanced-cljs-completion-p nil)
----
