Skip to content

Using the Figwheel REPL with Vim

Christoph Frick edited this page Aug 2, 2019 · 5 revisions

Requirements

Setup

As of v0.5.8, after following the setup guide you should have a project.clj like:

{
  :source-paths ["src/clj" "src/cljc"]

  :profiles
  {:dev
   {:dependencies [[figwheel-sidecar "0.5.8"]
                   [cider/piggieback "0.4.1"]]
    :source-paths ["src/cljs"]
    :plugins      [[lein-figwheel "0.5.8"]]}
    ...
  }
  :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}
  ...
}

Note: previous versions of Cider used: [com.cemerick/piggieback "0.2.1"] and cemerick.piggieback/wrap-cljs-repl for the middleware.

Start figwheel

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

Note you should have only one nREPL process starting, fireplace will connect there and create a cljs session.

Open the figwheel instance in your browser (usually localhost:3449).

In vim

It should auto-connect using the .nrepl-port file.

You can check the connection by eval'ing (cpp) a clojure file, if it takes less than a second (no repl starting cost) you're good.

Use :Connect to connect to the repl by hand.

Still in vim, Piggieback on Clojurescript

Run the following command to connect Fireplace to the Figwheel REPL (instead of the default Rhino repl):

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

For Fireplace 2.0:

:CljEval (cider.piggieback/cljs-repl (figwheel-sidecar.repl-api/repl-env))