Skip to content

Instantly share code, notes, and snippets.

@malyn
Created February 20, 2015 21:12
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save malyn/646e291d01101dcc8b48 to your computer and use it in GitHub Desktop.
Save malyn/646e291d01101dcc8b48 to your computer and use it in GitHub Desktop.
vim-fireplace patches/hack for compatibility with Figwheel
diff --git a/plugin/fireplace.vim b/plugin/fireplace.vim
index 6c32caa..a415bf8 100644
--- a/plugin/fireplace.vim
+++ b/plugin/fireplace.vim
@@ -232,7 +232,9 @@ function! s:repl.piggieback(arg, ...) abort
else
let arg = ' :repl-env ' . a:arg
endif
- let response = connection.eval('(cemerick.piggieback/cljs-repl'.arg.')')
+ "let response = connection.eval('(cemerick.piggieback/cljs-repl'.arg.')')
+ call connection.eval("(use 'figwheel-sidecar.repl-api)")
+ let response = connection.eval('(cljs-repl)')
if empty(get(response, 'ex'))
call insert(self.piggiebacks, extend({'connection': connection}, deepcopy(s:piggieback)))
@malyn
Copy link
Author

malyn commented Feb 20, 2015

You have to manually ":Connect" to the Figwheel nREPL (1, localhost, 7888, return) and then ":Piggieback" to establish the ClojureScript REPL. Everything should work as-is after that.

@malyn
Copy link
Author

malyn commented Feb 20, 2015

Note that if you create an .nrepl-port file first (with the contents "7888") then you only need to type the ":Piggieback" command -- the nREPL connection will be established automatically.

@lambdahands
Copy link

Stumbled upon this today. Can't thank you enough! This works great for me. 😄

@jebberjeb
Copy link

+1

@danielbraun
Copy link

Thank you for this!

@s-mage
Copy link

s-mage commented Sep 4, 2015

Wow. Man, thank you so much!

@venantius
Copy link

This unfortunately did not work for me. Anybody mind sharing a sample project.clj just so I can debug whether my problems are being caused by other configuration stuff?

@cassiomarques
Copy link

When trying to do cpr I get the following error:

Error detected while processing function <SNR>52_Require:
line   13:
E716: Key not present in Dictionary: user_ns()})
E116: Invalid arguments for function fireplace#session_eval

Any ideas? Thanks!

@danielbraun
Copy link

@cassiomarques Are you starting the repl using lein figwheel?

@Gonzih
Copy link

Gonzih commented Jan 13, 2016

Is this still relevant?

@jebberjeb
Copy link

@Gonzih I'm still having to use this hack because the method described here gets me an NPE. I'm thinking figwheel-sidecar.repl-api/cljs-repl is returning nil.

@styts
Copy link

styts commented Aug 12, 2016

I have to confirm that this patch is still relevant.

To reproduce, I've started a new figwheel template

lein new figwheel hello-world -- --reagent

Opened the figwheel repl via either lein figwheel (or lein repl, followed by (fig-start)).

Then opened a clojure file in vim and called :Piggyback. Then sent a form to the repl with cpp.

In the unpatched version, this was the error:

org.mozilla.javascript.EvaluatorException: Java class "[Ljava.lang.StackTraceElement;"
has no public instance field or method named "cljs$lang$protocol_mask$partition0$". (rhino.clj#41)^@'}

In the patched version, the result of e.g. (println "hello") appears in the browser console, the result of a side-effect-free evaluation (e.g. (+ 1 2))appears right in vim. Excellent!

@nenadalm
Copy link

nenadalm commented Nov 9, 2016

thanks. the patch works (took me a while to find it).

@Gonzih
Copy link

Gonzih commented Nov 14, 2016

According to this issue tpope/vim-fireplace#222 there is no need for this patch any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment