Question

Is it possible to connect vim.fireplace to a browser repl ? I have a setup using austin but if I try to evaluate something inside vim I get:

org.mozilla.javascript.EcmaError: ReferenceError: "setTimeout" is not defined. 

which seems to be an indicator that the browser repl is not used.

Was it helpful?

Solution 2

Yes it is possible. Browser repl, noderepl, rhino repl...

Checkout the docs and read about piggieback. That's how it handles the envs

https://github.com/tpope/vim-fireplace/blob/master/doc/fireplace.txt https://github.com/cemerick/piggieback

Piggieback is included on Austin too so it should work if you :Connect to Austin and then :Piggieback with the environment you want

Edit: example

Read https://github.com/cemerick/austin/blob/master/README.md#usage and look at the environment that corresponds to how you started the repl. For example :Piggieback (cemerick.austin/repl-env). Look at the docs to see different repl-env that you can try.

Edit 2: Sample project Vim nRepl and node repl

Check out this project and the instructions in the readme for something similar for nodejs

https://github.com/joakin/cljs-node-repl/blob/master/README.md

OTHER TIPS

I found this discussion on Reddit to be helpful.

Specifically, I've added these commands (as suggested in the post) to my vimrc as shortcuts depending on what environment I want to connect to:

command! Piggie :Piggieback (cemerick.austin/exec-env)
command! Biggie :Piggieback (cemerick.austin/exec-env :exec-cmds ["open" "-ga" "/Applications/Google Chrome.app"])
command! Wiggie :Piggieback (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001) 

Now, I can

  1. Start repl (lein repl or :Console)
  2. Start web app in repl (e.g. (run) when using a chestnut lein template)
  3. Open cljs buffer in vim.
  4. Connect to repl using commands (e.g. :Wiggie)
  5. Evaluate expressions in my buffer, and see live changes in the browser!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top