Fork me on GitHub
#conjure
<
2020-05-16
>
andre.stylianos01:05:10

Hello! I've made the jump from the legacy version to the new one and it's looking awesome! Props for all the work, once again 🙂 I've got one question that I wasn't able to solve by looking at the current documentation, though maybe I just didn't find it. Do we currently have an equivalent way of configuring multiple connections such as when we could have a .conjure.edn file with multiple conns configured? We have more than one service here, and I'm trying to figure out how to configure the connections and manage jumping from one to the other. The way we handled it in the legacy version was to declare the connections in the config file, all of them disabled by default and then :ConjureUp +service-name to connect to the service we were working on at the moment. Is this natively supported or something that I should configure with some vim commands?

Olical10:05:21

Hey! I'm glad to hear you've managed to update successfully! It's pretty different in some ways so I expect some friction, I'll help where I can. So the multiple connections concept is gone (for now?) because nREPL supports multiple sessions which means through one connection you could run your JVM web server, shadow-cljs and core JVM Clojure development evaluations. Rather than having many connections with many sessions (suuuuper confusing and hard to navigate IMO) I took the simpler route. The intended approach now is to use .nrepl-port auto connection when you have one REPL to worry about and :ConjureConnect [port] commands when you have multiple.

Olical10:05:51

I'd recommend a couple of mappings or commands you can run to easily connect to the REPL you're interested in. It should take the same amount of effort to switch REPLs but through massively different means. I think in the long run not having my own system of config files and rules about which file means what will be for the best. It's up to you and Vim Script to set it up for your needs which should be far more flexible than my own configuration and some regular expressions.

Olical10:05:28

I hope that's not too awkward for you! Feedback is much appreciated so I can make it smoother going forward for real use cases.

andre.stylianos18:05:02

Hey, definitely not an issue! It’s not the most common of cases and it’s something we can handle on our side without too much trouble.

andre.stylianos18:05:15

Just wanted to be sure I wasn’t overlooking anything native before devoting some time to doing it manually on our end.

andre.stylianos18:05:13

And your reasoning is sound for not including it as part of Conjure.

andre.stylianos18:05:31

Thanks for the support. I’ll probably tinker with it more on Monday, but I really liked what I’ve been able to test so far. :thumbsup:

🎉 4
Olical10:05:19

Finally happy that everything's as stable as I can get it for now so I can work on new / improved things!

Olical11:05:06

Oh that's a fun bug, I guess you can't issue window commands or define cursormoved commands in the command-line window?

Olical11:05:11

The more you know 🌈

Olical14:05:18

Trying to keep *1 *2 *3 in sync is causing me LOADS of problems :thinking_face: I can't eval any aux code for you since it messes them up.

Olical14:05:25

Kinda of want to drop support for them

Olical14:05:28

But not sure.

nate14:05:39

How are they used? I don't think I've ever used them.

Olical14:05:11

Yeah, my thinking is that they're rarely used and of negligible value, apart from *e. I have never once used them in anger.

Olical14:05:32

It's just a special REPL var that contains your last 1st, 2nd and 3rd evals. Every eval moves them along.

Olical14:05:44

This means I can't ever perform an eval for you as part of an eval in your session since it messes with this history.

nate14:05:52

Oh yes, once I learned ,ve I've been using that a lot.

Olical14:05:02

Yeah, the exception one is good.

Olical14:05:35

I'll keep bashing against it for a while and see what I get.

Olical14:05:20

Trying to make ns switching and auto require much more robust across shadow-cljs and shadow, it's taken me all day and I'm still not there. Every solution I come up with has a trade off, the least worst one being "it messes with the *1, *2, *3 history"

thheller15:05:36

whats the problem?

Olical15:05:23

Actually it works fine in cljs land, in-ns seems to not alter *1 which is great. In Clojure JVM land *1 is replaced by the result of in-ns. This just messes with the history because I want to execute in-ns before each eval.

thheller15:05:03

well if you are talking over nrepl you can set :ns as part of the message and shadow-cljs should respect it

Olical15:05:13

I can use (do (in-ns foo.bar) *1) to get around it, sort of. But that won't work in ClojureScript as far as I can tell, it wants in-ns to be a top level special form.

Olical15:05:53

Wait what. That's not documented for nREPL. If that's a thing everywhere then this is a non issue.

Olical15:05:56

It's suddenly trivial.

thheller15:05:13

shadow-cljs should support it. no clue about piggieback

Olical15:05:29

Will it require the ns if it's not loaded too?

Olical15:05:39

Don't worry

Olical15:05:46

Support as import, brain fart.

thheller15:05:50

no, but I could add it.

Olical15:05:01

Ehhh I would think that'd be assuming too much.

Olical15:05:04

But I'm not sure.

thheller15:05:36

to be honest I wouldn't want to build tools on top of nrepl or prepl. they are terrible protocols for tools imho.

thheller15:05:56

so anything this could do to make tool life easier it should do IMHO

Olical15:05:26

nREPL has grown on me a little, but the docs missing some things like this have really tripped me up.

thheller15:05:38

as I said .. I don't have a clue about the official other implementations

thheller15:05:49

I can only tell you what shadow-cljs supports (and could support if missing)

Olical15:05:55

Considering standardising my default namespace to conjure.user too so I don't have to constantly handle the difference between user and cljs.user

Olical15:05:07

Okay, pinch of salt taken, I'll give it a test

thheller15:05:11

{:op "eval" :code "::foo" :ns "foo.bar"} as nrepl message should be supported by regular CLJ eval and shadow-cljs CLJS sessions

thheller15:05:34

needs to be a string not a symbol because of bencode ...

Olical15:05:44

Yup, of course

Olical15:05:51

I'm experimenting now

Olical15:05:53

Thank you!

Olical15:05:36

Also, is there a guarantee that if I send two eval messages they will be run in order?

Olical15:05:03

So if I send a require and then use the resulting required namespace in two messages, could it get race-y? It can, right? Because require is async?

thheller15:05:11

in shadow-cljs it will wait for the first message to complete before processing the next

thheller15:05:22

in regular CLJS require is async and it will process the next directly, so it breaks things if you send too fast

Olical15:05:30

Interesting!

Olical15:05:39

I wonder if figwheel has this race problem too :thinking_face:

Olical15:05:47

I guess so since it's regular piggieback

thheller15:05:51

yes, it inherits the CLJS problem

Olical15:05:14

Curses. Well another problem for another day, right now I'm focusing on solid support for shadow and JVM.

Olical15:05:26

Figwheel should work, it might be a little flaky though because of this.

Olical15:05:30

Have some ideas to work around it!

Olical15:05:37

This is looking really good for Clojure 👀

Olical15:05:52

Any idea why clojure.test would be undefined in shadow though, @thheller :thinking_face: I thought I had it working.

Olical15:05:58

Ah, sorry. So I'm requiring clojure.test and then trying to use clojure.test/run-all-tests etc, but it's saying it's undefined. I don't think I need to use cljs.test, that hasn't been the case for ages.

Olical15:05:55

Just weird, I could've sworn I had this working.

Olical15:05:14

Don't worry, I'm sure it's my end, not shadow's fault.

thheller15:05:18

$ shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn
shadow-cljs - connected to server
cljs.user=> (require 'clojure.test)
nil
cljs.user=> (clojure.test/run-all-tests)

Testing shadow.cljs.devtools.client.console

Testing shadow.cljs.devtools.client.node-repl
...

Olical15:05:33

Yep, that's what I expect and have seen in the past.

Olical15:05:43

; --------------------------------------------------------------------------------
; run-ns-tests: dev.sandbox
; (err) ------ WARNING - :undeclared-ns ------------------------------------------------
; (err)  Resource: :1:30
; (err)  No such namespace: clojure.test, could not locate clojure/test.cljs, clojure/test.cljc, or JavaScript source providing "clojure.test"
; (err) --------------------------------------------------------------------------------
; (err) ------ WARNING - :undeclared-var -----------------------------------------------
; (err)  Resource: :1:30
; (err)  Use of undeclared Var clojure.test/run-tests
; (err) --------------------------------------------------------------------------------
; (err) clojure.test is undefined

Olical15:05:04

I can require it fine though, no errors, returns nil.

thheller15:05:09

that should probably show what you sent exactly 😛

Olical15:05:19

True, I'll check.

Olical15:05:52

I know what it is

Olical16:05:39

All looking good now! Was just something my side. So I pushed a fix for issue #90 and greatly improved the shadow + JVM clojure robustness, especially around the auto-require mechanics. That's now working really nicely!

Olical16:05:07

:ns on the eval is super helpful, thanks @thheller, I wish I'd known about it earlier. The only thing it doesn't let me do it select user or cljs.user depending on the REPL type.