4
votes

I just started playing around with making a simple cljs app using the following template:

lein new figwheel someproject -- --reagent

I was hoping to use the REPL in cider for cljs development the same way I typically would for a normal clj project, so I did some research and ended up here:

https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl

I read through the instructions, and verified that all the proper dependencies are in project.clj (didn't have to change anything, looks like the template added everything I would need). The final step in the above link indicates I would need to add the following code to my emacs config:

(require 'cider)
(setq cider-cljs-lein-repl
      "(do (require 'figwheel-sidecar.repl-api)
           (figwheel-sidecar.repl-api/start-figwheel!)
           (figwheel-sidecar.repl-api/cljs-repl))")

Now - I'm an emacs newb, so the setup I'm using is still the one I first learned on from "Clojure for the Brave and True":

https://github.com/flyingmachine/emacs-for-clojure

I tried to first put the above snippet in ~/.emacs.d/init.el, but whenever I attempt M-x cider-jack-in ..., there is no cider-jack-in-clojurescript option. I also tried putting the snippet in the ~/.emacs.d/customizations/setup-clojure.el, which seemed like a more logical home, but same result.

I'd really love to be able to get this REPL up and running, so any help would be appreciated.

1
As an emacs newb, I'd strongly advise using an Emacs distribution that comes with everything you need already set up for you. Emacs Prelude and Emacs Live are the major contenders -- and both are actively-maintained, as opposed to the one you link to which appears to have gotten no love for the last 3-4 years.Charles Duffy
Thanks @CharlesDuffy - while I've been learning Clojure I've tried to minimize the burden of diving into the details of emacs at the same time - too much at once. I've stuck with this setup just because I've gotten use to all it's packages/defaults etc and am cautious about starting from scratch and making sure I get everything setup properly again. I see your point though and will eventually move over to something more robust.Solaxun
@Solaxun Spacemacs with Clojure layer is also a good start. I started with the Brave and True setup as well, but Spacemacs provides way better defaults and batteries included (e.g., error messages always popping up in the same buffer instead of randomly; clj-refactor). The keybindings from Brave and True work there as well, and you can discover others by pressing , (major-mode) and see options pop up. 1. Install emacs. 2. d/l spacemacs. 3. Add clojure to ~/.spacemacs layers.Erwin Rooijakkers
I keep hearing good things about Spacemacs - The only reason I haven't moved onto something else (like Prelude, Spacemacs, etc) is just because I didn't want to invest the time with setting everything up again. But in reality I've probably only added a handful of things beyond the defaults so it shouldn't be too bad, maybe I'll give Spacemacs a shot. BTW - I've read your blog in the past (PAIP in Clojure) - really enjoyed it!Solaxun
@Solaxun haha awesome. Very good to hear. Maybe I'll finish chapter 5 someday :). Did you know PAIP?Erwin Rooijakkers

1 Answers

6
votes

I usually use plain cider-jack-in and then call everything from REPL:

(use 'figwheel-sidecar.repl-api)
(start-figwheel!)
(cljs-repl)

If you want to have two repls, you can do the final step (cljs-repl) in separate REPL opened via cider-connect.

If you are just starting with Emacs, I believe your best bet is Spacemacs: http://spacemacs.org/. If you are interested, I did a blog post and a video about my dev workflow.