Skip to main content

Make the Figwheel REPL work in vim-fireplace

I just have created a pull request with Vim-Fireplace, that allows passing down an expression to :Piggieback. This allows using the Figwheel REPL without much hassle.

First follow the instructions to create a Figwheel project. E.g. lein new figwheel example-project. Check the generated project.clj file and remove the comment on the line, that sets the nREPL port (:nrepl-port 7888, pick any port number you like).

To make Vim-Fireplace pick up the nREPL port create an .nrepl-port file containing the port number. E.g. echo 7888 > .nrepl-port. Otherwise connect from the Vim command line with :Connect nrepl://localhost:7888 (or follow the dialog with just :Connect).

In Vim then open any ClojureScript file (e.g. the generated src/example_project/core.cljs) and then enter at the Vim command prompt:

:Piggieback! (do (require 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/cljs-repl))

Now saving ClojureScript or CSS files will automatically (and statefully) reload in the browser. And all the regular things in Vim-Fireplace like evaluating expressions or requesting the docs work too.

For repeatability add this alias in your .vimrc (or in an after script for Clojure or Vim-Fireplace):

command! Figwheel :Piggieback! (do (require 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/cljs-repl))