Fork me on GitHub
#vim
<
2016-07-19
>
dominicm06:07:20

@juhoteperi: I also see :Source printed to browser console.

dominicm06:07:33

Eval works with results though :Eval (js/prompt "test") returns my input.

dominicm07:07:06

I see this with chestnut btw.

dominicm07:07:09

Hm, from the chestnut repl, when I run (cljs.repl/source om.dom/h1) I see it both printed in the browser and outputted to the repl. I think maybe that this PR with piggieback doesn't capture the output for some reason.

dominicm07:07:48

So anything that uses (println) isn't working with Figwheel + Piggieback.

dominicm07:07:54

Also worth noting that vimscript: echo fireplace#client().eval('(cljs.repl/source om.dom/h1)', {}) returns {'status': ['done'], 'id': 'fireplace-hostnames-1468910433-46', 'session': ['c09f9597-5a6f-4b9e-8b30-f20d0f32e4f1'], 'ns': 'cljs.user', 'value': 'nil'} So the eval implementation isn't picking up the result for whatever reason. Might be a difference between a repl-env and figwheel, unsure.

dominicm07:07:18

Funny enough, if I open the figwheel repl cli, and then go back to fireplace to run source I see the output there.

juhoteperi07:07:56

Eval response nil is okay, because source prints the result and returns nothing

juhoteperi07:07:29

There is some problem with Figwheel Repl println redirection, not sure yet what

dominicm07:07:32

Yep. But there's no out key.

dominicm07:07:10

{'status': ['done'], 'id': 'fireplace-hostname-1468910433-55', 'out': '(gen-react-dom-inline-fns) ', 'session': ['d937ad03-f2d3-46d4-bded-47d0fcef0200'], 'ns': 'user', 'value': 'nil'} This is from clojure for example. Which is what we'd expect. No idea how figwheel is supposed to work.

juhoteperi07:07:13

Figwheel should always redirect the output to both browser console and nrepl

juhoteperi07:07:36

Cljs repls work differently

dominicm08:07:35

I'll check with boot-cljs-repl now what the raw return should look like.

juhoteperi08:07:25

Both Weasel and Figwheel print the redirected output to \out\ at the point of repl creation

dominicm08:07:00

{'status': ['done'], 'id': 'fireplace-hostname-1468860905-76', 'out': '(defn atom (fn-body))', 'session': ['66da3ad2-a4e6-4638-ac9a-7d78b48d0997'], 'ns': 'cljs.user', 'value': 'nil'} But their raw nrepl op eval, returns an out key.

juhoteperi08:07:44

Aha, something to do how Piggienback catches the output

juhoteperi08:07:33

Or cider-nrepl, because I think that's only thing that is catching the output and adding it to the response

juhoteperi08:07:40

But why would this work with weasel but not figwheel

dominicm08:07:11

Maybe it's piggieback that it works with? Figwheel implements it's own cljs-repl "thingy"

juhoteperi08:07:19

No, Figwheel uses Piggieback

juhoteperi08:07:34

It replaces Weasel

dominicm08:07:45

Oh, I really need to get my head round this relationship.

juhoteperi08:07:02

Piggieback is the nrepl middleware which needs to be used to provide eval-op support for cljs repls

juhoteperi08:07:11

Weasel is WebSocket Repl server & client

juhoteperi08:07:19

Figwheel has it's own Repl server & client

juhoteperi08:07:40

server in this case = http server with web socket

juhoteperi08:07:24

Editor sends eval command -> Cider nrepl wraps it (sets \out\ to specific value) -> Piggieback sends it to active Repl which is built using figwheel or weasel env -> Sends command to the browser over WS -> Browsers evals the stuff -> Sends response over WS back to the server (and sends outputs over WS to the server) -> Cider nrepl adds catched output to the response

dominicm08:07:33

I see. That's a huge pipeline. I think I get it though.

dominicm09:07:44

:Source works if I do boot dev instead of boot cider dev. I agree this is a CIDER problem.

juhoteperi09:07:53

Hmm what does cider task do?

juhoteperi09:07:10

Do you have cider middleware setup at profile.boot?

juhoteperi09:07:47

I wonder if the order of middlewares could matter...

dominicm09:07:16

I'm really stupid. Ignore me.

dominicm09:07:25

The problem isn't boot.

dominicm09:07:28

Boot works.

juhoteperi09:07:28

I thought this means that out middleware requires piggieback

dominicm09:07:30

Lein fails.

dominicm09:07:50

Okay, what I said is still true.

dominicm09:07:05

When I disable the plugin in leiningen, :Source works.

dominicm09:07:24

Trying with manual specification of :nrepl-middleware

dominicm09:07:32

I'll try fiddle with order

juhoteperi09:07:53

Which plugin? Cider?

dominicm09:07:13

Yes, CIDER. Although I did disable refactor-nrepl also, so it's possible that's a culprit.

dominicm09:07:02

With cemerick.piggieback/wrap-cljs-repl before and after the cider.nrepl.middleware.out/wrap-out middleware, I am unable to run :Source

dominicm09:07:19

Hmm, but it's still a problem with that cider middleware enabled.

juhoteperi09:07:53

Not working reliably without cider-nrepl for me

dominicm10:07:56

It works sometimes then?

juhoteperi10:07:30

I think it worked once, can't reproduce

dominicm10:07:24

Hmm, strange. Maybe it's below cider then, and cider reading *out* just triggers the underlying problem.

dominicm10:07:10

Yeah, I can't repro either it seems.

dominicm10:07:31

That's frustrating. I thought we had it then.

dominicm12:07:50

If we figure out a way to get it to work, it might be worth checking the value of *print-fn*, to see who owns it.

juhoteperi12:07:00

Afaik that works, you can check websocket connection from dev tools and you should see that Figwheel sends the message from browser to repl server

juhoteperi12:07:25

and figwheel server code receives the message and prints it, I have debugged this far, for some reason it prints to wrong buffer

dominicm12:07:46

I think it's supposed to print to all buffers.

dominicm12:07:55

I do wonder if maybe the output isn't being caught in time?

juhoteperi12:07:19

it is supposed to print to special buffer created by Cider which redirects output to other buffers

juhoteperi12:07:37

Or Tools.nrepl if Cider is not used

dominicm12:07:49

ah, I see. You're well ahead of me then.

dominicm17:07:50

Piggieback! (cemerick.piggieback/cljs-repl (adzerk.boot-cljs-repl/repl-env)) works seamlessly, which is nice.

dominicm18:07:25

That implies something that vim expects is incorrect. I am completely stuck on what though

dominicm18:07:20

I should have perhaps tried that with fireplace's python lib

dominicm19:07:57

Works with fireplace's python library also. No way am I releasing this ugly-ass code though.

dominicm19:07:59

So it's something about how fireplace interacts with a piggieback I guess

dominicm19:07:18

Maybe it is cloning too much.

juhoteperi20:07:06

Piggieback (adzerk.boot-cljs-repl/repl-env) works fine also

dominicm21:07:15

I wanted to confirm that it wasn't something to do with the patch