Clojure/Clojurescript and Vim: A beginner's perspective

Hi all,

I’m quite new to Clojure, and I’ve been working on a side project in figwheel on and off for a few months. The bulk of my project is in ClojureScript. When I was working by myself, I had trouble setting up my ClojureScript repl to work with vim-fireplace. Even with help from @plexus we had a lot of trouble trying to get Vim, vim-fireplace, and Piggieback working together. Most of the open GitHub issues addressing these problems were many years old. I had some luck running a ClojureScript repl in another terminal window, but it was definitely a hindrance keep switching windows around and I felt like I was missing out on a lot of great development tools.

I eventually gave up, and I’m now using Spacemacs. Switching editors works for me right now, but it seems pretty cumbersome for someone who spent years working on their Vim configuration and just wants to try out ClojureScript.

I’m a lurker in Clojureverse and a Clojure newbie, but there seems to be a lot of discussion about building community and fostering growth in the Clojure community. I think more public support of Vim (documentation, more public discussion here) would definitely help Vim users who are curious about Clojure feel more comfortable learning the language. Vim users - what is your Clojure workflow like? Have you also run into issues using Piggieback and Vim fireplace?


I’m mostly happy using vim with vim-fireplace for Clojure development. I’ve actually never quite gotten a nice setup for ClojureScript though. I think it’s possible to tell fireplace that you’d like to connect to the ClojureScript repl by using some fireplace command referring to the nrepl port. I vaguely recall that I might have gotten that far once, but couldn’t figure out how to make it more automatic or preserve the regular Clojure connection. Perhaps this is something vim-fireplace needs to grow towards?

1 Like


I struggled to get a decent Vim + ClojureScript setup for a while, but found the instructions at Using the Figwheel REPL with Vim helpful.

Specific steps that work for me:

$ lein new figwheel vimtest
$ cd vimtest
$ lein repl

In the REPL:

user=> (use 'figwheel-sidecar.repl-api)
user=> (start-figwheel!)

In your browser http://localhost:3449.

$ vim src/vimtest/core.cljs

In Vim, execute:

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

In Vim, insert:

(println "Hello browser")

Then use vim-fireplace to eval that line (type cpp in normal mode) and you should see the message in both Vim and the browser console.

I’m using the latest tpope/vim-fireplace 265fc95 and:

$ vim --version
NVIM v0.2.1-dev

Thank you so much for the writeup @zakak, I tried it and it works! We did basically exactly that yesterday but kept getting errors. I’ll have to compare the two project.clj files to see what we were doing differently.

I’m super happy just to know that this actually still works with the latest vim-fireplace, figwheel, and clojurescript. I was starting to believe that they were simply no longer compatible, but luckily that’s not the case.