I was looking forward to experimenting with the new release of ClojureScript but I'm running into a problem when trying to evaluate code.
I have an nREPL server running and am (seemingly?) able to connect to it using :Fireplaceconnect localhost:$PORT
. However, when I try to evaluate code (using either :Eval
or :CljsEval
) I see an error message which says, "Fireplace: no default ClojureScript REPL".
There's an issue in the fireplace.vim repository which mentions this problem, but it was closed with RTFM -- I have and I still can't figure out a solution.
{
:aliases {:nREPL
{:extra-deps
{nrepl/nrepl {:mvn/version "0.7.0"}
cider/piggieback {:mvn/version "0.4.2"}}}}
}
> clj -R:nREPL -m nrepl.cmdline --middleware "[cider.piggieback/wrap-cljs-repl]"
I was able to find a workable solution and have documented the entire workflow here:
deps.edn:
{
:aliases {:rebel {:main-opts ["-m" "rebel-readline.main"]}}
:paths ["src" "resources" "target"]
:deps {cider/cider-nrepl {:mvn/version "0.25.0-alpha1"}
cider/piggieback {:mvn/version "0.5.0"}
com.bhauman/figwheel-main {:mvn/version "0.2.6"}
com.bhauman/rebel-readline {:mvn/version "0.1.4"}
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
nrepl/nrepl {:mvn/version "0.7.0"}
org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/clojurescript {:mvn/version "1.10.773"}
reagent {:mvn/version "0.10.0"
:exclusions [cljsjs/react cljsjs/react-dom]}}}
Inside a Clojure REPL run the following commands to start the nREPL server, ClojureScript REPL and Figwheel build:
(require '[fullstack.helpers :refer :all]) ;; import nREPL helpers
(start-nrepl-server!) ;; start nREPL server on 7888
;; Some people run the following commands using Vim-Fireplace's `:CljEval`
;; command but I found that to be a little clunky.
;; If I do end up using this workflow regularly, I'll consider packaging these
;; steps up in a VimScript helper function.
;; Out of habit, I send them from this document inside vim to a parallel tmux
;; pane using vim-slime.
(require 'figwheel.main.api) ;; require Figwheel's scripting API
(figwheel.main.api/start "dev") ;; start Figwheel build (using dev.cljs.edn) and REPL
Within Vim, run the following command in the CLI prompt (hit :
in command mode) in order to connect to the running ClojureScript REPL:
:Piggieback (figwheel.main.api/repl-env "dev") " connect to the CLJS REPL
The major differences are moving the dependencies to the local deps.edn (this is not necessary, but I think it's a better, more flexible approach), upgrading Piggieback and leaning on the higher level Figwheel scripting API, instead of CLI flags.