Fork me on GitHub
#conjure
<
2020-05-02
>
pyrmont02:05:56

Has anyone used new Conjure with Figwheel without Leiningen? I have something hacked together but it feels like I'm doing something wrong.

pyrmont03:05:20

OK. So this is how I've got things working at the moment: https://gist.github.com/pyrmont/73d10c74d14f26772fd276c38ee3490d I'm not sure if the nrepl.clj file is necessary. It feels like this is something that Figwheel should support (and possibly does) that I simply haven't set up correctly.

Olical09:05:37

This looks good! I do feel like lein-figwheel should be booting an nREPL server for you though :thinking_face:

pyrmont09:05:34

Oh, it would, I'm sure. I'm just trying to have a workflow that doesn't use Leiningen at all. Call me perverse.

Olical09:05:08

Ah okay! Yeah I don't use lein either, figwheel-main all the way. I think some CLJ projects can have their nREPL started from cmd line args alone, but only for simple cases.

Olical09:05:49

As soon as you start working on a bigger project you tend to move towards a namespace / some in project tools to boot up your nREPL (I also used to add socket prepl code in there when I outgrew propel on projects)

Olical09:05:08

With CLJS, if you're not using shadow, I think you kinda need a bit of code like you have.

Olical09:05:56

Shadow-cljs does just work in my experience so far, I really like it. If you wanna try Conjure and Shadow here's the config I use to test https://github.com/Olical/conjure/blob/develop/shadow-cljs.edn Sets up nREPL and CIDER out of the box 😄

pyrmont10:05:32

I've hesitated to use Shadow because it feels too much like magic. But maybe that's irrational and no more or less true than Figwheel.

pyrmont11:05:15

I am getting frustrated that after a couple of hours, I can't get a version of this script working that will call a shutdown hook when it finishes. I don't know what's going on but for some reason when I end the CLJS REPL, the entire thing just stops and nothing more runs.

pyrmont11:05:41

But in any event, not the fault of Conjure.

Olical11:05:26

Hmm, yeah things like shutdown hooks + CLJS sounds like a bad time, even without trying. A bunch of things that just work with JVM Clojure just don't translate well since you're dealing with weird eval environments that may or may not respond in the right way.

Olical11:05:56

There's so many places and ways CLJS can be evaluated, I think a shutdown hook would be tricky. Or do you mean in JVM land you have a shutdown hook?

pyrmont11:05:09

JVM-land.

pyrmont11:05:23

I just want to automatically delete the .nrepl-port file.

Olical11:05:48

Ah I see! I guess it's just a case of getting the JVM incantation correct.

pyrmont11:05:17

Both deleteOnExit and addShutdownHook aren't working so long as I make a call to figwheel.main.api/cljs-eval which feels nuts to me. I've tried everything I can think of (wrapping that call in a future, running it in a separate thread) but nada.

pyrmont11:05:33

Anyway, it's not a Conjure problem :)

pyrmont11:05:44

And not even that big a deal to be honest.

Olical11:05:38

Unless it's setting it's own shutdown hook which overrides it? Yeah, deffo not Conjure but still annoying :thinking_face:

pyrmont11:05:53

Yeah. What I was hoping I could do rather easily was create some middleware that you'd add to your Figwheel project and pass options to like figwheel.main and it would basically do everything it did but just started an nREPL, saved the file for the port and deleted it when you shut it down. Make it as close to 'just works' as it could conceivably be without changing Figwheel itself.

pyrmont11:05:27

Anyway, sorry for the trouble and sorry for coming at you with all these comments at the last hour. We just hit a five-day weekend in Japan so have more time than usual :)

Olical11:05:53

Well shadow-cljs spits its portfile out into .shadow-cljs/nrepl.port, if figwheel already does something similar (has it's own file) I can add that to the list!

Olical11:05:04

Oh neat! Enjoy the weekend! 😄

👍 4
Olical11:05:40

Conjure supports hunting for multiple kinds of port files, I'll get it to hunt up the dir tree soon too.

Olical11:05:11

I'll make that configurable actually

pyrmont11:05:26

Oh, well, Conjure works fine. It's just the file might be there and you don't have an nREPL instance running. But that's not the end of the world. Conjure fails gracefully.

pyrmont11:05:50

If I remove the rebel-readline dependency, the problem disappears! I like rebel-readline but at least I have a sense for where it's coming unstuck now. (Sorry, this isn't relevant to Conjure but I needed to express this relief to someone.)

Olical11:05:44

I'm very glad it works! 😄

Olical11:05:38

I think @dharrigan had an issue with rebel conflicting with the nREPL CLI too

dharrigan11:05:21

Yeah, I fire up my own nrepl now inside of user.clj

pyrmont19:05:40

Updated the code I have to run an nREPL in Figwheel without Leiningen: https://gist.github.com/pyrmont/73d10c74d14f26772fd276c38ee3490d I'm setting the Figwheel configuration option :rebel-readline to false because if I have rebel-readline enabled, the REPL won't shut down cleanly (and if it won't shut down cleanly, it won't call .File.deleteOnExit and remove the .nrepl-port file). If anyone knows if there's a way to fix this, please let me know.

dharrigan19:05:33

I've borrowed this bit of code...

pyrmont19:05:04

@dharrigan Cheers! Yeah, I want to use .File.deleteOnExit but using rebel-readline via figwheel.main.api is causing it not to be called for some reason. Problem goes away if I don't use it. It's a bit of a shame because I like it.

dharrigan19:05:52

np, good luck! 🙂

👍 4
pyrmont03:05:37

It seems like the default namespace is always user, even if the type of REPL is ClojureScript. Am I wrong to think that it should be cljs.user if it's a ClojureScript REPL? I'm mucking around a bit in a file with no namespace only to find that when I switch to the default Figwheel REPL (that's open in cljs.user), the bindings are over in user (which the Figwheel REPL complains about if I try to switch to because it's a single segment namespace).

Olical09:05:38

Ah good catch! I'll fix that, I think I had it working for both but removed it while refactoring early on.

Olical10:05:30

Another nice thing about being faithful to how stdout in a terminal displays, test output looks just like the terminal!

; --------------------------------------------------------------------------------
; run-ns-tests: dev.sandbox
; 
; Testing dev.sandbox
; 
; Ran 2 tests containing 2 assertions.
; 0 failures, 0 errors.

Olical10:05:01

(that's in cljs)

Olical10:05:14

@mike858 The default namespace for CLJS environments is now cljs.user 🎉

👏 4
pyrmont11:05:12

@olical Is there a way to change the background colour of the HUD? I have a similar issue to @dominicm (I think) where the colour I use for comments makes it difficult to see output there that's commented out (i.e. docs).

pyrmont11:05:36

Sorry if this is somewhere in the docs. I had a look but missed it if it was there.

dominicm11:05:46

@Olical the HUD uses the virtual window color

dominicm11:05:55

Sorry *floating window color

dominicm11:05:58

I forget what that defaults to

dominicm11:05:23

Normal maybe?

pyrmont11:05:32

@dominicm Cheers. That's enough to have Google help me work out what to adjust :)

dominicm11:05:58

Normal just to highlight it

👍 4
Olical11:05:25

As far as I'm aware it's actually the pop up menu background :thinking_face:

Olical11:05:41

Someone else had an issue with their theme being too light and not having enough contrast.

Olical11:05:39

Added config for which port-files to check for a port, see docs 🙂

Olical11:05:51

(currently .nrepl-port and shadow-cljs' one

Olical12:05:42

Conjure will now hunt up the directory tree for all port files too. So you can change which files get checked and you can connect to them while your CWD is deep within your project.

👍 8
Olical12:05:16

Go to def and load-file also still seem to work if you're in a different Neovim CWD to your REPL.

Olical12:05:24

@dharrigan Added a better fix for the go to def hud flash, it shouldn't appear at all now unless something goes horribly wrong.

dharrigan12:05:40

fantastic - will check shortly 🙂

dharrigan12:05:02

Hmm, still flashes

Olical12:05:26

Oh, I know why!

Olical12:05:14

Should be fixed now, I had a second log output I didn't spot

Olical12:05:34

So I need to suppress the HUD when the request comes through from you and also when it completes working out the path.

Olical12:05:57

Since it tells you where it jumped to (which is kinda pointless since you're looking at it). You can still open the log to see the workings out.

Olical12:05:14

(I could never see the flash in the first place, but it might be down to laptop speed and vim settings)

Olical12:05:29

Another flicker bytes the dust

dharrigan12:05:35

mother flicker...

Olical12:05:54

Well that's my pre-release todo list cleared out again. Might do some more docs.

dharrigan12:05:48

I've been using the new conjure since Friday and really, it works very very well 🙂

dharrigan12:05:57

Almost a seamless transistion from old to new.

dharrigan12:05:07

but far faaaaaster startup 🙂

Olical12:05:06

I'm very glad to hear that! It'd be great to get the interactive :ConjureSchool implemented soon too. One of my visions for this (possibly silly) is for people that are new to Clojure / Lisps that know a little bit of Vim to use this.

Olical12:05:26

I want the out of the box experience to just be "open file, run code", but give you the tools and config to tweak it into the future.

Olical12:05:45

Would be awesome to have beginners using this stuff.

dharrigan12:05:09

Initially, I thought the "hud" would be annoying

dharrigan12:05:14

but no. I was very wrong. It's great.

Olical12:05:32

😄 🎉 it can always be turned off too, I put that setting in with you in mind

dharrigan12:05:34

What abatted my fears was that it disappears on keymovement.

Olical12:05:58

You can also change the size to keep it suuuper small. Size is based on Neovim window size.

Olical12:05:10

Right now it's a little less than half the width and height of your editor.

dharrigan12:05:13

No I like it - when I eval a form/buffer, I like to see it have a result, then as soon as I move my cursor, puff - like MAGIC it disappears.

dharrigan12:05:24

magical, conjure 🙂

Olical12:05:48

Yep! So if you're just editing away and not looking it's more of a visual confirmation in your peripheral vision that something happened.

Olical12:05:29

I think I'll probably reintroduce some virtual text stuff at some point too. I think the best use would be function signatures with some simple highlighting, but I'll see.

Olical12:05:30

Would also be cool to maybe flash the code you evaluated or something as confirmation. And also display icons in the gutter that show which lines have been evaluated or changed since last eval (just like CIDER in Emacs). All configurable of course.

dharrigan12:05:53

All great ideas. I look forward to the next round of development!

Olical12:05:40

Well I'm going to watch the last Mandalorian episode, write more Aniseed docs and thing about the announcement blog post 😄

dharrigan12:05:21

I enjoyed that series a lot

dharrigan13:05:25

This isn't a conjure question, but perhaps someone might know. Is there a way to subtly change the background colour of the form block that the cursor is in? To visually show the scope, if you know what I mean, of the block. As you move the cursor up and down, between forms, the subtle background highlight would change shape. I know, presently, that I rest my cursor on an opening, or closing, parens, it shows it's counterpart, but I'm after showing the entire block 🙂

dharrigan13:05:33

(I'll ask in #vim too)

Olical13:05:21

Ohh that'd be cool. I think it'd be pretty tricky to implement right now, would probably have to be a plugin :thinking_face: (could be implemented with Aniseed and Conjure!) Maybe another thing tree-sitter integration would make absolutely trivial too.

dharrigan13:05:20

I'm sure this is a solved problem, it's basically highlighting the inside of a block, between matching parens, or curly braces (if javascript for example)

dharrigan13:05:33

but yeah, probably needs some language awareness

Olical13:05:59

Hmm, you'd need to check the highlight stack (trace?) For a tag saying "you're in a form". Not sure if that exists

Olical13:05:45

Then you'd need to somehow change the highlight of that ONE specific form

Olical13:05:59

By maybe adding some new tag to it, I think that part is doable

Olical13:05:36

Maybe Conjure's form finding code would be enough... I have the code right now to ask "get the form under my cursor and where it starts / stops"

Olical13:05:42

so if you had an autocmd for cursor move

Olical13:05:10

you could luaeval("require('conjure.extract').form()") from vim script

Olical13:05:29

which would return a map with two keys, range and content

Olical13:05:40

then you could use that range to apply a highlight. Although that's where my knowledge ends.

dharrigan13:05:50

more knowledge than moi 🙂

Olical13:05:52

Could be a fun little plugin that piggiebacks off Conjure's lua public fns!

Olical13:05:10

I kinda want people to write plugins that just reach into Conjure and use stuff

dharrigan13:05:22

I could try, but later 🙂

Olical13:05:24

Yeah, of course. Just musing about the potential, I really like the idea!

dharrigan13:05:42

we can talk about this later - let you get on with your conjure stuff 🙂

pyrmont19:05:40

Updated the code I have to run an nREPL in Figwheel without Leiningen: https://gist.github.com/pyrmont/73d10c74d14f26772fd276c38ee3490d I'm setting the Figwheel configuration option :rebel-readline to false because if I have rebel-readline enabled, the REPL won't shut down cleanly (and if it won't shut down cleanly, it won't call .File.deleteOnExit and remove the .nrepl-port file). If anyone knows if there's a way to fix this, please let me know.