Search code examples
emacsclojureclojurescriptciderfigwheel

Is there an easier way to use BOTH clj + cljs REPLs at the same time from emacs/cider?


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 :)


Solution

  • 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.