Fork me on GitHub
#vim
<
2018-04-14
>
dominicm14:04:04

https://ibin.co/w800/3yMaL6T95x2i.png I wrote an ANSI parser for echo output

upside_down_parrot 4
dominicm14:04:57

actual motivation is for use with spyscope

dominicm15:04:30

I've pushed this up in replant, you can see it working on https://github.com/juxt/edge when using replant's "work-anywhere reset" (`<localleader>rf`)

dominicm15:04:49

https://ibin.co/3yN4fHRnBfa1.png Combined with aviso's pretty (using eval) this could be quite useful, but I'm not sure yet 🙂

lwhorton18:04:46

heya guys — has anyone been able to get vim-fireplace to work with a .cljs file and nrepl?

lwhorton18:04:52

i’ve been trying shadow-cljs which provides an nrepl, and also uses piggieback to wrap that nrepl so in theory I should be able to connect from vim -> .clj file connet to nrepl -> eval piggieback -> .cljs file eval buffers

eraserhd18:04:30

Hmm... I'm not sure I've tried it...

lwhorton18:04:56

well if you remove shadowcljs from the equation — its typically:

lwhorton18:04:30

1) start nrepl server 2) connect to js environment (via browser) 3) do some sort of piggieback on the nrepl to go from clj -> cljs

lwhorton18:04:13

shadow’s nrepl provides all the middleware for cider as well as cemerick.piggieback’s cljs-repl

lwhorton18:04:33

but it’s like my vim-fireplace just refuses to work in any .cljs buffer — though I can connect and evaluate both clj and cljs environments from a .clj buffer

eraserhd18:04:03

Interesting. I'm out of my depth 🙂

eraserhd18:04:12

I should learn more about how the cljs tooling works.

dominicm18:04:45

@lwhorton how are you doing the piggieback?

dominicm18:04:06

I helped thheller test this, so I am confident that it works.

lwhorton18:04:30

at which point do I call :Piggieback? let me get you the debug stack here …

lwhorton18:04:41

1) start a shadow server 2) from inside a .clj buffer connect via :Connect <nrepl://localhost:port> 3) I can now use :Eval (+ 1 2) and get 3 (yay the connection to nrepl works) 4) cannot use :Eval from inside a .cljs buffer (always spits out Fireplace: class clojure.lang.Compiler$CompilerException) 5) from a .clj buffer run shadow...api/watch :app — get back :watching — success! 6) connect to the js environment by opening a browser 7) still no Eval in a .cljs buffer 8 ) from a clj buffer run shadow...api/nrepl-select :app — get back [:selected :app] — success! 9 ) from a clj buffer :Eval (js/alert) yay it works 10 ) still nothing works from a .cljs buffer

dominicm18:04:40

You need to do :Piggieback :app

lwhorton18:04:45

after step 5 do I have to manually :Piggieback :app?

dominicm18:04:10

Maybe even instead of. But I'm uncertain.

lwhorton19:04:08

it looks like the short-order is : nrepl -> connect -> open js in browser -> piggieback app -> bingo

dominicm19:04:06

that sounds right

🎉 4
dominicm19:04:16

@eraserhd I'm starting on a test -> quickfix runner for replant. Hopefully it will scratch your itch.

dominicm19:04:28

(combined with the signs plugin previously mentioned)

eraserhd19:04:53

I'm actually fixing parinfer issues right now.

dominicm19:04:46

Great 🙂 I've had a few annoyances recently, I am probably due a pull though

dominicm19:04:15

gah, I'm gonna have to make some changes on the cider-nrepl side, the only thing they report when there's a failure is "api_test.clj", like that's useful

dominicm19:04:29

Not even edge/api_test.clj, so weird

dominicm19:04:54

Maybe I will experiment with doing a round-trip for each failure.

dominicm20:04:02

@eraserhd is this the sort of thing you were after? https://ibin.co/3yOGqZ3ZVIHo.png

eraserhd20:04:14

Definitely.

eraserhd20:04:19

er, "Definitely!"

dominicm20:04:16

The E vs W is for free from quickfix, yay!

dominicm20:04:26

So, for every var tested, I have to send a round-trip op to get the file for the var 😔

dominicm20:04:33

maybe it's fast enough though, let's see.

dominicm20:04:43

https://ibin.co/w800/3yOVtTK4bMMy.png Quite pleased, the diffing is a nice improvement over fireplace: https://ibin.co/w800/3yOWLZV1nauw.png

nate16:04:00

@dominicm trying out replant today, and was wondering how you got the diff part in the first screenshot?

nate16:04:21

my test:

(deftest testertester
  (testing "Another thing"
    (is (= {:foo "bar" :baz "bars"}
        {:foo "bar" :baz "bar"})))
  (testing "Another thing"
    (is (= {:foo "bar" :baz "bars"}
        (throw "test"))))
  )

dominicm16:04:35

@U0510902N that should just work, it did where I tried it. What are you getting?

nate16:04:58

and I get

test/app/model/test_test.clj|8 warning| app.model.test-test/testertester
|| Testing Another thing
|| expected
|| (= {:foo "bar", :baz "bars"} {:foo "bar", :baz "bar"}) 
|| actual
|| (not (= {:foo "bar", :baz "bars"} {:foo "bar", :baz "bar"})) 
test/app/model/test_test.clj|11 error   1| app.model.test-test/testertester
|| Testing Another thing
|| expected
|| (= {:foo "bar", :baz "bars"} (throw "test")) 
|| exception message
|| java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Throwable
|| To inspect stacktrace, run: :ReplantTestStacktrace app.model.test-test testertester 1

nate16:04:05

I get the expected and actual

nate16:04:07

but no diff

nate16:04:00

in neovim, java8

nate16:04:41

btw, the :ReplantTestStacktrace works well and is awesome

dominicm16:04:19

Just curious, what if it's outside of "testing"?

nate16:04:00

how do you mean?

nate16:04:10

like this?

(deftest testertester
  (is (= {:foo "bar" :baz "bars"}
        {:foo "bar" :baz "bar"}))
  (is (= {:foo "bar" :baz "bars"}
        (throw "test")))
  )

dominicm16:04:16

yeah. Does that work?

nate16:04:13

unfortunately no, same result

nate16:04:47

|| expected
|| (= {:foo "bar", :baz 1} {:foo "bar", :baz 2}) 
|| actual
|| (not (= {:foo "bar", :baz 1} {:foo "bar", :baz 2}))

nate16:04:04

changed the values just to be sure I was evaluating the right thing

dominicm16:04:51

Just curious, what cider version?

dominicm16:04:30

I run against 0.17.0-SNAPSHOT, so it might be that diffing is new, or recently-fixed

nate16:04:46

cider 0.16.0

nate16:04:50

lemme try the snapshot

nate16:04:14

|| expected
|| {:foo "bar", :baz 3} 
|| actual
|| {:foo "bar", :baz 4} 
|| diff
|| - {:baz 3} 
|| + {:baz 4}

nate16:04:27

had to bump my refactor--nrepl up too

nate16:04:31

to snapshot

nate16:04:29

one question, if I do :ReplantTestProject after editing and saving my test, it doesn't pick it up

nate16:04:56

I do the fireplace cpr and then :ReplantTestProject and that works, but runs the tests twice

nate16:04:11

do you have another keybinding for just reloading the current test namespace?

nate16:04:26

or do you do the reload one from replant?

dominicm16:04:45

I think cpr is a bit magic and requires the current namespace before running. That may or may not work in some circumstances. I was doing a combination of ,rf and cpaF as appropriate, yep.

dominicm16:04:19

I wonder if it should refresh before running tests, automatically? Something to consider for sure.

nate16:04:29

I think that would be good

dominicm16:04:47

a full refresh might be too heavy handed, feel free to open an issue for discussion. I want to think on this one a little more than other things, because I think there's a high risk of breaking people's systems.

nate16:04:12

oh yeah, definitely

nate16:04:15

I'll open an issue

nate16:04:32

and to be clear, I just mean refreshing the test namespaces before testing

nate16:04:36

not the whole app

dominicm16:04:59

Oh, interesting. I don't know if cider supports that yet. I wonder if it's even possible :thinking_face:

nate16:04:04

however, it's hard to know if that will be sufficient, because what if I changed code somewhere else that makes the test work

dominicm16:04:16

The problem with the way that fireplace reloads is that it's famously broken.

nate16:04:28

I found I can do :Require and then ReplantTestProject

dominicm16:04:32

Anyway, we can try and get to the bottom of this in the issue, where it's permanently recorded 🙂

nate16:04:41

that just reloads the file I'm in and runs tests

dominicm16:04:02

Yup, good old (require 'x :reload)

dominicm20:04:18

https://github.com/SevereOverfl0w/vim-replant/issues/16 I opened this for discussion. I tried to be thorough.

nate20:04:47

Oh wow, that is super thorough

nate20:04:52

reading it in detail

dominicm20:04:51

Good choices are hard

nate20:04:12

the best ones are

nate20:04:30

:ReplantReadMyMindAndFigureItOut

dominicm20:04:43

🧠 💥

dominicm21:04:06

Also notable, the line numbers are right ^^

mynomoto22:04:26

@dominicm I'm tempted. What should I expect comparing with fireplace?

dominicm06:04:07

Replant augments fireplace, if you don't like it, don't run the commands and keep using the fireplace ones.

dominicm06:04:50

Or, only use the replant ones you like

mynomoto13:04:55

Cool! I thought it replaced it.

dominicm13:04:11

Nope, I can understand why you would think that though. Long term it's my goal.

dominicm14:04:53

I've tried to update the README to clarify this.

dominicm06:04:07

Replant augments fireplace, if you don't like it, don't run the commands and keep using the fireplace ones.