Vim + Fully functioning REPL + Auto reloading

618 views
Skip to first unread message

Tristan Strange

unread,
Feb 23, 2015, 9:44:06 AM2/23/15
to clojur...@googlegroups.com
Hi all,

In light of the recent REPL fixes what's the simplest means of configuring a project that allows me to both:

- Evaluate expressions from Vim to a browser based REPL
- Have figwheel style reloading files.

Should I look to Weasel to provide the REPL and disable's figwheel's built in one?

Are either needed at all now the problem's with ClojureScript's own REPL's have been 'fixed'?

Many thanks,
Tristan

David Nolen

unread,
Feb 23, 2015, 10:01:24 AM2/23/15
to clojur...@googlegroups.com
There are still changes that need to propagate to Piggieback. And regardless of Piggieback, currently a lot of REPLs unnecessarily do things in slightly different ways (some of these, but not all, attributable to the fact that previously Piggieback could *not* reuse the existing REPL loop and had to copy pasta loop logic, with the obvious problem that it's out of sync now). Other problems have to do with previously undefined contracts, like any failure in REPL setup should fail the REPL.

All this to say - I would wait a bit. The foundation is better but there is still some catch up to do.

David

--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Alan MacDougall

unread,
Feb 23, 2015, 1:00:11 PM2/23/15
to clojur...@googlegroups.com
On Monday, February 23, 2015 at 8:44:06 AM UTC-6, Tristan Strange wrote:

>what's the simplest means of configuring a project that allows me to both:
>
> - Evaluate expressions from Vim to a browser based REPL
> - Have figwheel style reloading files.

I recommend using Figwheel's REPL within a screen or tmux instance, and use vim-slime to push to it.

https://github.com/jpalardy/vim-slime

I use this approach for anything REPL-like, from ClojureScript to Pry (a Ruby REPL) to shell scripting.

Tristan Strange

unread,
May 17, 2015, 7:29:51 AM5/17/15
to clojur...@googlegroups.com
Hi, 

Has any progress been made with this?

I've just tried a Chestnut and a Tenzing template and have been unable to connect to a browser REPL via Vim fireplace in either environment.

Many thanks,
Tristan

Gary Verhaegen

unread,
May 18, 2015, 9:06:36 AM5/18/15
to clojur...@googlegroups.com
You can get Vim to work with Chestnut today [1] :


  1. Open vim
  2. Back in the terminal, run lein repl
  3. In the repl, do (run)
  4. In vim, open the cljs file and do

    :Piggieback (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)
    
  5. Open browser to http://localhost:10555/

  6. In vim, cqc (js/alert "woohoo!")


It is important to respect the order of the steps; in particular, something within Vim breaks if you try to evaluate anything (step 6) before connecting a browser (step 5).

I have only tested that with Chestnut "stable", so pretty old versions of ClojureScript (0.0-2511) and Om (0.8.0-rc1) by now (and Clojure 1.6.0, so no cljc). Still feels awesome, though.

Gary Verhaegen

unread,
May 19, 2015, 4:56:57 PM5/19/15
to clojur...@googlegroups.com
So, of course, first time I try this again after posting, it does not
work anymore, because my fireplace.vim is "too" up-to-date. The
:Piggieback command in Vim results in a not so helpful
"IllegalArgumentException No value supplied for key:
weasel.repl.websocket.WebsocketEnv", which is due to a change in
Piggieback API. The latest fireplace would presumably work with the
latest Piggieback, but chestnut lags a bit behind.

So to get chestnut to work with Vim and the latest fireplace, one has
to change the fireplace code a bit to reflect the older Piggieback
API: at line 300 in plugin/fireplace.vim you need to change

let response = connection.eval('(cemerick.piggieback/cljs-repl'.arg.')')

to

let response = connection.eval('(cemerick.piggieback/cljs-repl
:repl-env '.arg.')')

Since this is not a very good solution if you are working with
multiple projects, some of which use an older Piggieback and some
others a newer one, a less invasive solution is to change step 4 in my
previous message to be:

:Piggieback :repl-env (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)

Happy vimming!

Geraldo Lopes de Souza

unread,
May 21, 2015, 7:14:53 PM5/21/15
to clojur...@googlegroups.com
Tristan,

I'm coming back to cljs and went initially for chestnut road.
I was with the impression that I needed repl inside vim.
That was not the case, When things seatle it ll be very nice.
But I found that vim clojurescript figwheel are awesome.

Here is my project.cjl
https://gist.github.com/geraldodev/d6ec4ce41dfc60411a0c

I ve noticed that with compiler options: main and asset-js I can use one same index.html for dev and prod.

And figwheel does a awesome job using cljsbuild info. It's awesome how code is live patched before I Alt-tab :)

Good luck

Tuomas Järvensivu

unread,
Jun 23, 2015, 7:56:50 PM6/23/15
to clojur...@googlegroups.com
I just started working on a Clojure + ClojureScript proto and had some troubles getting seamless REPL integration to work with Clojure and ClojureScript.

I finally managed to get the workflow working seamlessly so I decided to write a blog post about it:

http://uhef.github.io/cljproto-blog//2015/06/10/clj-cljs-vim-repl.html

Hopefully it helps!

Leon Grapenthin

unread,
Jun 24, 2015, 4:51:10 AM6/24/15
to clojur...@googlegroups.com
I thought vim fireplace connects to nrepl? Is it not possible to use figwheels nrepl like this https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl ?

tuomas.j...@gmail.com

unread,
Jun 25, 2015, 3:16:17 AM6/25/15
to clojur...@googlegroups.com
Leon:
The approach with figwheel (+sidecar) sounds good. I think I tried that at some point already with not much success but perhaps I could give this another try later this week. I suppose using figwheel repl would remove dependencies to weasel and piggieback (since it comes with figwheel) plus one probably wants to have figwheel included in the project setup anyway.

On Wed, Jun 24, 2015 at 11:51 AM Leon Grapenthin <grapent...@gmail.com> wrote:
I thought vim fireplace connects to nrepl? Is it not possible to use figwheels nrepl like this https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl ?

--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/hISetjDRnsA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages