Fork me on GitHub
#conjure
<
2020-05-01
>
Anthony Khong07:05:55

Hi, I have a question about Conjure’s eval. Is it possible to exclude a function from clojure.core , replace it with another function in the namespace and do eval with the new function. Concretely, suppose I have:

(ns some-app.core
  (:refer-clojure :exclude [count]))

(defn count [_] 1)
With Conjure’s eval, I get:
; lein/eval | (ns some-app.core (:refer-clojure :exclude [count]))
; lein/ret ⤸
nil
; lein/eval | (defn count [_] 1)
; lein/ret ⤸
#'some-app.core/count
; lein/eval | (count [1 2 3])
; lein/ret ⤸
3
But on the actual REPL:
user=> (ns some-app.core
  #_=>   (:refer-clojure :exclude [count]))
nil
some-app.core=>

some-app.core=> (defn count [_] 1)
#'some-app.core/count
some-app.core=>

some-app.core=> (count [1 2 3])
1
Looking at the plugged/conjure folder, I’m on commit ed91dba and NVIM v0.4.3. Would appreciate any help I can get! Cheers!

Olical14:05:33

Ah, you're on the older Conjure! I'm about to release the one on the develop branch which is a total rewrite. It doesn't have this issue (I just tried it) and it uses nREPL instead of prepl (like every other Clojure tool) which is VERY well documented.

Olical14:05:03

Would you like some help upgrading? I promise the new experience is better in near enough every way. It has a very similar UX, just polished and a lot easier to get started.

Anthony Khong14:05:12

I can try upgrading! Do you have a set of instructions? It’s not on the docs yet right?

Olical14:05:46

So everything you need should be here https://github.com/Olical/conjure/tree/develop and once installed, in :help conjure (to work out how to configure mappings etc)

Anthony Khong14:05:29

Got it, I’ll give it a go. Thank you so much for looking it up!

Olical14:05:34

Essentially, swap to develop, remove the bin/compile stuff (no longer needed). Start an nREPL server then open a Clojure file. nREPL is standard basically everywhere, Conjure was the weird one using prepl 😅

Olical14:05:58

But yeah, tried it in the new one and it worked fine, before I realised you were on the old version.

Olical14:05:19

I'm basically soft deprecating the currently released version already, my rewrite is just a lot better.

Anthony Khong15:05:57

Hi Oli, I managed to get it to work after half an hour of tinkering! The new Conjure is awesome! Definitely a more seamless experience to get started. I do have one question though, in the old Conjure, the log buffer opens automatically, and I could adjust the log size. However, in the new Conjure, I have to do <localleader>lv to open it. This is not as good as before because i) I have to trigger it, ii) the active pane becomes the log buffer, so I have to move over and iii) I have to resize it. Is there a command that I can use to open the log buffer, so that I’m at least one nnoremap away? Edit: managed to get this to work nmap <Space>al <Space>lv<C-W><C-H>:exe "vertical resize " . (winwidth(0) * 5/4)<CR>. I think it’s okay now!

Olical18:05:45

Oh sweet, well done for working it out! Yeah, there's no special way to do that right now

Olical18:05:01

When I get around to implementing some sort of event system you can hook into "log opened" and resize then too

Olical08:05:46

Oh that's really interesting, thanks for the report! I can't actually see a reason why that wouldn't work. I'll take a stab at it!

👍 1
Olical08:05:16

Like I'm setting the NS to some-app.core before the eval, so count should be that. I'm never specifying "I need clojure.core" (other than for things like load-file)

dharrigan11:05:18

Anyone experience the issue (I don't think this is releated to conjure, could be vim-clap?) where the pop-up window appears, but never goes away - have to restart vim...

dharrigan11:05:41

I can't get rid of that window now

Olical11:05:37

Oh that's odd, yeah, wouldn't be conjure. I can get vim clap into a broken state like that. I just restart vim

dharrigan11:05:43

I'm using Conjure II and it's working well so far 🙂

dharrigan11:05:58

did you get round to looking at the "gd" from yesterday?

Olical14:05:33

The HUD shouldn't show up when you gd now unless something goes wrong 🙂

dharrigan14:05:03

will try shortly

Olical11:05:40

Not yet, I'll be attacking that a little later

dave14:05:28

i think you can click into the box and press Ctrl-w and then c

dave14:05:45

(i don't think that's part of my personal config? 🙂 )

Olical14:05:02

I found a way the HUD could get stuck open: If you save it and don't have bufhidden set, when it closes (or tries to) Vim will say no because it's not saved and it's the last window of that buffer!

Olical14:05:38

I don't really know how you could cause this...

Olical14:05:05

but now if you managed to get the HUD window to fail to close (still don't know how you'd do this unless you actively set things in the log buffer), it won't lose sink

Olical14:05:24

So if it's a temporary error you can just move the cursor again and it'll close, it won't become a phantom window you can't kill.

Olical14:05:35

Slightly more resilient!

Olical14:05:54

Implementing log-close-visible too

Olical14:05:08

Under <prefix>lq by default.

Olical14:05:40

Writing plugins in Fennel is a joy

(defn close-visible []
  (let [buf (upsert-buf)]
    (close-hud)
    (->> (nvim.tabpage_list_wins 0)
         (a.filter
           (fn [win]
             (= buf (nvim.win_get_buf win))))
         (a.run! #(nvim.win_close $1 true)))))

👀 1
Olical14:05:33

Done, you can now use <prefix>lq to close all visible log windows in your tab (including the HUD!)

Olical14:05:17

So if everything's still looking good on Monday (maybe earlier?) I think I'll release this candidate! Started working on Aniseed documentation too since it goes hand in hand with this.

Olical14:05:53

Got a big list of things to do after release, but I'm happy with the feature set and stability of develop right now, I think it's a great replacement for master, please correct me if I'm wrong!

Olical14:05:09

If anyone wants to write up some wiki recipes let me know too 🙂

Olical15:05:59

Had a little cleanup, all of those are fixed by develop 😬

nate15:05:51

👍 for Monday release on Star Wars day

Olical15:05:10

Yes! I didn't realise!

Olical15:05:25

Gives me more time to document and stuff over the weekend + maybe people will find issues if they're doing weekend hacking.

Olical15:05:19

If anyone wants to write up a wiki page with a workflow (regular JVM, shadow-cljs, CIDER etc) then please let me know. I'm going to write some soon but more than happy for others to jump in front with how they like to set things up!

Olical15:05:48

Or write a blog post and I'll feature it on the Wiki. I've marked all of the existing posts and stuff as for the legacy-jvm branch, so I need some fresh articles now 😄

Olical15:05:06

More than happy to feature blog posts as sort of blessed 3rd party docs.

dominicm15:05:58

jeez, I better invent a new feature for you

dominicm15:05:08

BUT DOES IT USE MONADS? HA!

dominicm15:05:12

not even type safe. Try harder.

dominicm15:05:48

I'll try and find time this weekend to have a play :) Or maybe in 10 minutes... Entirely predicated on whether my Cljs still builds after running sed over it.

dominicm15:05:57

I'll stop trolling you at some point too, promise

Olical15:05:12

Haha, definitely not type safe. And yeah, any feedback will be really appreciated! In theory the whole nREPL side is covered, muuuuch more "it just works" than prepl. The stuff that could break would be UI/UX or plugin / OS conflicts.

Olical15:05:48

When it was prepl based, the transport and the UI were my problem. Now it's mostly UI/UX (until I start fixing piggieback or nREPL things)

dominicm15:05:41

I feel like we've gone down the same journey now (except you worked harder) 😀 It's a thorny path. I'm thinking being nREPL/cider based is going to make things work more smoothly for me & my esoteric setups

Olical15:05:00

Yep, I think a lot of things will "just work" now and I can't wait. I know you swap out your eval function? So maybe I need to add some config to allow that sort of thing? But it's possible now.

rgm15:05:05

@olical is it a known thing that make compile on develop fails on macos? (seems to be because Darwin cp lacks the -u option).

Olical15:05:32

Yep, RosaControl on twitter pointed that out, I think she fixed Aniseed's repo and I need to port the change over to Conjure's makefile?

rgm15:05:53

ah, ok … was gonna contrib if not.

rgm15:05:29

(seems like some sed shenanigans too:

deps/aniseed/scripts/compile.sh
deps/aniseed/scripts/embed.sh aniseed conjure
sed: 1: "lua/conjure/aniseed/eva ...": extra characters at the end of l command

Olical15:05:36

I can't find a cp with -u :thinking_face:

Olical15:05:58

Ah! In embed.sh

rgm15:05:28

that’s the one.

rgm15:05:43

I just removed it to brute-force things.

Olical15:05:45

Hmm, maybe without -u is the same... not sure why I need it now, maybe it was just a guard that I added without really needing it.

Olical15:05:15

If it works totally fine without it maybe I should remove it, that'd be a change to Aniseed.

rgm15:05:35

-u, --update
              copy only when the SOURCE file is newer than the destination file or when
              the destination file is missing
according to the linux server I’m ssh’d into right now.

Olical15:05:16

Yep, so I don't really know how it'll behave without it :thinking_face: I don't think it's required.

dave15:05:16

mac vs. linux sed discrepancies are the bane of my existence

dave15:05:23

i've been bitten by sed -i a few times

dave15:05:33

on mac, you have to do sed -i '' for some stupid reason

rgm15:05:52

henceforth I am referring to these as sednanigans

😂 3
rgm15:05:41

happy to contrib a patch for embed.sh that uses this oft-used snippet of mine. Seems cp -r and sed -i '' "s/,,," gets me to a passing make test

dave15:05:11

this is my hack around the sed -i issue:

if [[ "$(uname -s)" == "Darwin" ]]; then
  edit_in_place='-i ""'
else
  edit_in_place="-i"
fi

sed $edit_in_place ...

dominicm16:05:36

I ended up just using perl

dominicm16:05:47

it comes as a dep of git, so pretty much everyone has it

Ryan Campbell16:05:13

I just started using the new conjure in develop and I'm really liking it. One "issue" I noticed is that (compared to fireplace) it doesn't seem to do as good a job finding .nrepl-port. Fireplace uses findfile() to search up from the current file (i think?), while conjure seems to just looks in the currrent working directory. Any chance that functionality could be added?

Olical16:05:08

Ah yes, that's a very good point! Was thinking about this the other day actually 😅 I'll add it to the list

Olical16:05:13

Might be able to add it before cutting a release

Ryan Campbell16:05:35

thanks! Great work so far (on aniseed too, i'm in the proces of converting all my vim config to use aniseed.dotfiles and it's so nice)

Olical16:05:51

Oh that's great to hear! I'm working on documenting aniseed properly using vim help too!

dharrigan16:05:58

Hi @olical still flashy flashy with the hud, although for a millisecond

Olical17:05:12

Ah damn, I did a bit of a quick fix 😅 I'll try to address it a little nicer

pyrmont16:05:19

Not sure if this is a bug or not but I just did the following:

(print "Hello world")
And then <localleader>eb. The output when I do this is nil (which is fine) but there's no other output at all. If I instead use println then it works (as I would expect it) and outputs nil while also recording that "Hello world" was sent to stdout.

pyrmont16:05:35

This is using the current develop connecting to Babashka.

pyrmont16:05:05

Everyone says this but I'm also compelled to note how ridiculously lightweight this feels. Maybe that's partly Babashka but wow.

Olical16:05:24

Oh yeah, it goes to the terminal you started the repl in sadly

Olical16:05:29

That's just a BB thing

pyrmont16:05:13

Hmmm. It's not printing out there but understood if that's BB's problem.

Olical16:05:37

Ah okay, when I tried it I saw all stdout going to the terminal I started the nREPL in :thinking_face:

Olical16:05:54

Mentioned it in the channel but it's a hard thing to call, you might want stdout there

pyrmont16:05:05

For what it's worth, writing (print "Hello world") in BB's REPL (not nREPL), does output "Hello world".

Olical17:05:38

Ah, worked out what it is!

Olical17:05:46

Babashka's nrepl implementation doesn't (flush) after eval!

Olical17:05:55

And you should always flush. It's good hygene.

Olical17:05:10

So if you (do (print "foo") (flush)) it'll work.

Olical17:05:28

I think it just needs to be added to bb, probably really easy!

pyrmont17:05:48

That makes sense. I'll file an issue in their repo.

nate19:05:46

is there a way to get the async completion working with babashka?

nate19:05:58

omni complete does work well

dominicm20:05:53

first bit of feedback: conjure doesn't try and find my .nrepl-port file if I start the nrepl after launching vim. It just shouts at me that it doesn't work. I think auto-connect on eval etc is ok

dominicm20:05:55

Something I got used to with fireplace is that it auto-requires the current ns :thinking_face: I'll probably adjust to that

Olical20:05:56

Oh, the prefix then cf will rehunt for a portfile

Olical20:05:20

Like when you switch file it loads the NS?

dominicm20:05:30

I think when I do something the first time.

dominicm20:05:24

It would be cool if Conjure converted ANSI escape sequences into highlighting. As it's a buffer you can rip off some of the ANSI highlighting plugins

dominicm20:05:37

(In edge I spit out some messages in color in order to highlight them)

dominicm20:05:37

I mentioned this with Conjure before, but docs should not be comments in the popup buffer. They're harder to read, especially in floating windows. Ideally they'd be their own type that gets highlighted. Here's how I did it in replant: https://github.com/SevereOverfl0w/vim-replant/blob/c2e2e7e18a47b246735c909e3afba9ce861e463b/src/replant.lisp#L79-L194 But a good start would be just not using comments tbh.

Olical20:05:13

Yeah, that's already in the issues list, been there a while, the escape sequences I mean

Olical20:05:20

There's a Lua based plugin that does this actually

dominicm20:05:15

Basics seem to work though, quite pleased :) Better exp than I had last time.

dominicm20:05:18

I could see myself using this.

🎉 1
Olical20:05:29

Hmm, maybe a syntax + making it an actual comment because I want the log buffer to all be valid clojure

Olical20:05:34

It'll break loads of tools otherwise

dominicm20:05:11

Pop it in a separate buffer maybe?

Olical20:05:01

Mmmm kinda goes against my whole "everything is in the log buffer for history reasons" :thinking_face: I'll keep it in my head, for now maybe tweak how your comments show up? Mine are very readable.

Olical20:05:07

Or is it just the fact that there's no highlighting?

dominicm21:05:14

It's the lack of distinction from the surroundings tbh.

dominicm21:05:50

I'm really sensitive to fonts/color, so I've spent a lot of time tuning it, so I apologize. But the docstring doesn't stand out at all. I have to scan, a lot to pick out what I'm looking for.

dominicm21:05:19

Run a few docs in a row and you can't see anything anymore.

dominicm20:05:16

yeah, stick it in preview

dominicm20:05:04

RE g:conjure_config, does this mean I can't use it after the fact?

dominicm20:05:39

I'd prefer to not use a custom command for config, I'd rather just use g:/b: variables as applicable.

Olical20:05:20

Oh there is! That's :ConjureConfig

Olical20:05:36

g:conjure_config is purely for those lazy loading Conjure, so the command isn't around yet.

Olical20:05:56

oh you don't want the command I see

Olical20:05:14

it's custom because I store them all as data within lua land, where the data types are nice and the water is warm

Olical20:05:39

Also I need fast non-interop access to them all the time and I don't know if the C bridge incurs a slight penalty in a tight loop

Olical21:05:03

If you need programmable access to the config that can easily be provided.

Olical21:05:28

Other reason for the custom command is to give you a nice syntax for configuring the generic conjure things as well as configuring the individual language clients

Olical21:05:41

(conjure has config and the clojure.nrepl client has it's own config)

dominicm21:05:43

Sorry, missed your thread reply 😀

dominicm21:05:01

> If you need programmable access to the config that can easily be provided. It's more that, I don't want to learn new stuff too much. I know motions, I know mappings, etc. If you had skipped <Plug> and not given me a way to define my own mappings using nmap I'd be equally frustrated. I want to minimize knowledge, I'm very lazy.

dominicm21:05:20

I think you can technically watch g: in order to be notified of updates if you need to cache something in response.

dominicm21:05:52

99% of the config can probably live in g: as it's not in tight loops.

Olical21:05:22

:thinking_face: I'll give it some thought, it's a big change for the system, but might be worth it

dominicm21:05:35

thanks for taking the time :)

dominicm20:05:01

I know how to get the current value of one of those, I don't know how to use this custom config system

dominicm21:05:54

Conjure marks it as an "initial config", hmm. Not a big fan tbh. Like, I know I can do g:conjure_nrepl_refresh_before to get current before, or get(g:, 'conjure_nrepl_refresh_before', 'dev/stop') to get it or a default, etc. I'd rather use vim concepts I already know, than learn a new system.

dominicm21:05:44

Just looked at :nmap, It would also be useful to have <Plug> mappings for everything so you can change the lua without me caring. I see there's some prefix thing, but being able to decide that ",E" is too difficult to type compared to "cp" is something I can't choose in the current system. <Plug> mappings give me that. Prefixes are a handy tool in plugins, but an option to disable outright is good too.

Olical21:05:35

You can totally change it to cp :D

Olical21:05:55

Wrap it in a list to break it out of the prefix

Olical21:05:06

It's sort of a DSL that I can extend in the future if required

Olical21:05:14

So a second arg could contain opts or something

Olical21:05:40

But yeah, "E" becomes ["cp"] and now it's unprefixed

dominicm21:05:51

Oh, I see... Custom again... I'd rather just use nmap, I know that already

dominicm21:05:19

nmap cp <Plug>ConjureEval