3
votes

As a beginner Clojurian I may need some help trying to understand if there is any way to solve my pain points of working with Cider REPL.

Context: I have a full-stack app(limunius on backend + re-agent/figwheel on frontend). I start the server from emacs/Cider Repl and can access all the namespaces of the running server from that REPL(which is super handy).

In another tab I run:

lein figwheel
Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid ;)
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - app
Compiling build :app to "target/cljsbuild/public/js/app.js" from ["src/cljs" "src/cljc" "env/dev/cljs"]...
Successfully compiled build :app to "target/cljsbuild/public/js/app.js" in 4.113 seconds.
Figwheel: Starting CSS Watcher for paths  ["resources/public/css"]
Figwheel: Starting nREPL server on port: 7002
Launching ClojureScript REPL for build: app

All cljs namespaces are accessible from this figwheel REPL/tab but it is not connected to Cider/emacs so I can only copy and paste there.

Is there a simple way to have both REPLs in emacs and quickly switch between them?

Or what's your typical workflow? Do you use backend and frontend REPLs but not at the same time? Sorry, I'm just learning so I need both :)

2
I don't use emacs, but in Calva (VS code extension), I just run two different instances of cider separately for clojurescript and clojure. I also run two different workspaces of vs-code for clojure/clojurescript. Works really well.Sergey Shvets

2 Answers

2
votes

You definitely can connect to both CLJ and CLJS at the same time with CIDER. Check the section Managing Connections from the CIDER docs. TL;DR: you can use C-c C-x c m to call cider-connect-clj&cljs.

That being said, for CLJS in general I'm a lazy and I leave figwheel to recompile on save and I check if the front-end looks like what I'm trying to do.

Edit: My setup is generally two vertical frames, code on the left and REPL on the right, most of the time evaluate expressions inline with C-c C-e and if I need anything that spans for multiple lines I write it on a (comment ,,,) block at the end of a namespace. I don't use C-C C-z to switch between code and REPL very frequently.

Also: I use stock Emacs 25 in Ubuntu 18.04 with a minimal setup but I've met people that have much more elaborate workflows using Spacemacs.

3
votes

Certainly you can! First connect to repl via cider-connect-clj that was opened on port 7002 (Figwheel: Starting nREPL server on port: 7002), then run (figwheel-sidecar.repl-api/cljs-repl) in the repl minibuffer that popped up. Then you'll have fully functioning cljs repl running along with clj repl - you can switch between them with cider-switch-to-repl-buffer (you will be taken to clj repl when in clj file, and to cljs repl when in cljs file)