How to setup deps.edn project with cider

When developing with source code buffers rather than directly in the REPL buffer, setting the main namespace is not required as all evaluation is done with respect to the namespace of the active source code buffer.

In Spacemacs the source code buffers and REPL buffers are all connected to the running REPL process. What you do in one is available from the other as its all in the REPL process.

In the source code buffer:

SPC m s n or , s n set the namespace in the REPL and therfore update the REPL buffer. This would be the same as (in-ns 'namespace) in the REPL buffer.

SPC m e b or , e b will evaluate the buffer, loading in the namespace and all Clojure code into the REPL, making them accessible in the REPL buffer.

SPC m e f or , e f evaluates whole expressions in the REPL, making them accessible in the REPL buffer.

Evaluating code within the source code buffer is simpler than using the REPL buffer and provides a simple way to save code to a Clojure file.
https://practicalli.github.io/spacemacs/evaluating-clojure/

It is possible to configure aspects REPL starts up and a common approach is to use the default user namespace to evaluate code. Typically this code is put into a dev/user.clj file with a :dev alias that included the dev/ directory in the class path.
http://practicalli.github.io/clojure/clojure-tools/configure-repl-startup.html

In CIDER (Spacemacs/Emacs), create a .dir-locals.el file to include the :dev alias which should then run the code from the dev/user.clj file.

((clojure-mode . ((cider-preferred-build-tool . clojure-cli)
                  (cider-clojure-cli-global-options . "-A:dev"))))  

https://practicalli.github.io/spacemacs/clojure-projects/project-configuration.html

2 Likes