Karen Fisher
Karen Fisher

Reputation: 777

How to make cljs files works with figwheel repl via fireplace.vim?

I have a project on ClojureScript and I'm using vim for code editing, so I want to access repl inside editor, what is accessible using fireplace.vim.

It works well if you have a brand new flat project - you just open the directory, start clojure repl, open vim in the same directory, create an expression and evaluate it using cpp.

https://youtu.be/vHDLDNoAdLE

But when I working with figwheel project I want to connect to figwheel repl in order to calculate something from cljs file, so I start a figwheel which starts the repl on port 7888 eventually and connect to that repl with fireplace using :Connect command and it works for only clj files, not for cljs.

https://youtu.be/ue42Yh0v6UQ

When I'm trying to evaluate an expression in .cljs file fireplace throwing this error:

Error detected while processing function 37_printop1..37_opfunc[35]..fireplace#client: line 10: E605: Exception not caught: Fireplace: class java.lang.ClassNotFoundException

Does anyone have any idea how to make it work (fireplace + .cjls files)?

Upvotes: 5

Views: 362

Answers (3)

Aliaksandr Sushkevich
Aliaksandr Sushkevich

Reputation: 12374

Here is a sequence of steps I took to make work figwheel REPL with vim fireplace:

  1. Add these dependencies to /home/{username}/.clojure/deps.edn:
...
  :aliases {:nrepl
            {:extra-deps
             {nrepl/nrepl {:mvn/version "0.6.0"}
              cider/cider-nrepl {:mvn/version "0.23.0"}
              cider/piggieback {:mvn/version "0.4.2"}}}}
...
  1. Add these ones to the project:
...
 :deps  {com.bhauman/figwheel-main {:mvn/version "0.2.3"}
         figwheel-sidecar          {:mvn/version "0.5.19"}}
...
  1. Run a project from a terminal with the next command:
clj -R:nrepl -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware cider.piggieback/wrap-cljs-repl]"

  1. Connect to an nREPL from vim using:
:Connect nrepl://localhost:{port}
  1. Start a figwheel REPL and connect to it:
:CljEval (do (require 'figwheel.main.api) (figwheel.main.api/start "dev"))
:CljEval (do (use 'figwheel.main.api) (figwheel.main.api/cljs-repl "dev")) 

Upvotes: 1

user2609980
user2609980

Reputation: 10484

Have you "Piggiebacked" ("enable the use of a ClojureScript REPL on top of an nREPL session") to connect Fireplace to the Figwheel REPL?

:Piggieback (figwheel-sidecar.repl-api/repl-env)

See https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-with-Vim#still-in-vim-piggieback-on-clojurescript

Related to ClassNotFound Exception cemmerick.piggieback:

You have to include cemerick.piggieback in your project.clj or profiles.clj. See https://github.com/nrepl/piggieback:

:profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.1"]
                                [figwheel-sidecar "0.5.18"]]
                 :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}}

Upvotes: 1

Karen Fisher
Karen Fisher

Reputation: 777

The problem was in fireplace.vim plugin

at line 323 in fireplace.vim

let response = connection.eval("((or (resolve 'cider.piggieback/cljs-repl)"

must be line:

let response = connection.eval("((or (resolve 'cider.piggieback/wrap-cljs-repl)"

because cider.piggieback defines wrap-cljs-repl function in line 299:

(defn wrap-cljs-repl [handler]

Upvotes: 1

Related Questions