conjure

:neovim:+:clj: https://github.com/Olical/conjure - If you're enjoying Conjure and want to say thanks: https://github.com/users/Olical/sponsorship :smile: (alt https://conjure.fun/discord)
dominicm 2020-07-26T09:09:19.030900Z

@nate fwiw, vim-jack-in can open the repl in tmux

Olical 2020-07-26T11:39:12.031Z

:thinking_face: thank you for the information! I guess if there's LOTS of results I could be doing something inefficient while processing the results, I could definitely try to optimise that. Are there lots of results as far as you can tell? Like, thousands? LuaJIT is pretty damn fast (understatement) and all I'll be doing is mapping some strings into some tables, something that's pretty simple.

Olical 2020-07-26T11:44:23.031200Z

I suppose there could be some things in here I could make faster (looking at the source). But not by much, I'm wondering if I'm doing more work up front to extract the context, I guess Fireplace does the same? (like it sends the context code so you get (let [...] ...) completions? That's unlikely to be the culprit, but let g:conjure#debug = v:true might highlight it. It'll show how quickly the completion request is sent after you request completions at least. And how many results you're getting!

Olical 2020-07-26T12:08:43.031500Z

I've pushed some slight optimisations to develop for this, you may notice a difference! I've never had enough completions to cause a slow down really, so I should probably try to reproduce this and work at making that faster.

Olical 2020-07-26T12:09:56.031800Z

Thanks for the heads up! I wasn't planning on this time around since I recently started a new job, I won't be able to justify a mini sabbatical this early on I don't think.

Olical 2020-07-26T12:09:58.032Z

One day though!

Olical 2020-07-26T12:10:54.032200Z

For now sponsorships are really helping my motivation, I'd eventually slide my time to be 80% workwork and 20% Conjure / OSS anyway, I used to work 4 days a week and I'd like to go back to that eventually.

1
Olical 2020-07-26T12:12:22.032500Z

From my experience vim-jack-in works great for this and does write the port. Here's the args I use for clojure cli (without the deps.edn part but still)

clj -A:nrepl:cider \
    -m nrepl.cmdline \
    --middleware "[cider.nrepl/cider-middleware]" \
    --interactive

Olical 2020-07-26T12:12:53.032700Z

I have a feeling the interactive flag ensures the .nrepl-port file is created?

Olical 2020-07-26T12:13:36.032900Z

As for lein, is should definitely make the file :thinking_face:

Olical 2020-07-26T12:14:37.033100Z

--interactive should create the .nrepl-port file from clj cli fwiw 🙂 https://clojurians.slack.com/archives/CK143P6D7/p1595765542032500

dave 2020-07-26T12:49:10.035400Z

I think it might even be able to figure out that it's inside tmux and use tmux automagically? I remember using vim-jack-in inside tmux and being pleasantly surprised that my REPL opened in a tmux window

dominicm 2020-07-27T07:40:50.044600Z

It does, yep!

dave 2020-07-27T14:34:35.047100Z

💯

2020-07-26T14:30:43.035500Z

Oh, wow. Thanks a bunch! I'll take a look at this as soon as I can!

Olical 2020-07-26T14:39:23.035700Z

I'm semi-concerned it'll make 0 difference, but I replaced a bunch of higher level function calls with much simpler direct calls out to Lua builtins.

Olical 2020-07-26T14:39:41.035900Z

So maybe it was my fn overhead in a tight loop that was causing it to be O(n^2) slow or something like that

2020-07-26T15:14:04.040200Z

Is there a way to configure pretty printing at the moment? At first, I thought conjure was leveraging nrepl-middleware to print to the log buffer, but i haven't been able to do (set! nrepl.middleware.print/*print-fn* zprint.core/zprint) so perhaps not?

Olical 2020-07-27T09:20:14.044800Z

Nice! Glad to hear it! Should have it released this week too 😄

Olical 2020-07-26T15:15:03.040500Z

It is indeed using nREPL for pprint

Olical 2020-07-26T15:15:07.040700Z

One sec will check

Olical 2020-07-26T15:16:32.041Z

Conjure sends conjure.internal/pprint to the REPL on connection and sets nrepl.middleware.print/print for each eval

Olical 2020-07-26T15:16:54.041200Z

I don't think you can just set the print-fn to any old fn, I think it has to have a certain signature

Olical 2020-07-26T15:17:11.041400Z

:code (.. "(ns conjure.internal"
               "  (:require [clojure.pprint :as pp]))"
               "(defn pprint [val w opts]"
               "  (apply pp/write val"
               "    (mapcat identity (assoc opts :stream w))))")}

Olical 2020-07-26T15:17:21.041700Z

So I think it needs to take value, writer and options map.

2020-07-26T15:17:43.041900Z

hm. I was following the example here https://nrepl.org/nrepl/usage/misc.html#_pretty_printing

Olical 2020-07-26T15:17:45.042100Z

Pretty sure if you don't meet that contract it silently fails and just falls through to a default?

Olical 2020-07-26T15:18:17.042300Z

Including the zprint-pprint wrapper function?

2020-07-26T15:18:38.042500Z

it's funny they give an example of setting print-fn and then afterwards explain the wrapper. sorry if the error is between the keyboard and computer here!

Olical 2020-07-26T15:19:19.042700Z

Yeah, maybe the docs could be improved there :thinking_face: I remember being thoroughly confused when I was first implementing the print option at the nREPL message level

2020-07-26T15:26:13.042900Z

2020-07-26T15:27:21.043300Z

I tried using the wrapper, but to no effect. None of the changes seem to affect the log printing

Olical 2020-07-26T15:27:30.043500Z

:thinking_face:

Olical 2020-07-26T15:40:15.043700Z

Not really sure what's going on right now but I'm off to cook some dinner, might be worth running it past #cider or #nrepl? I feel like it's more a problem with getting that config exactly right

Olical 2020-07-26T15:45:25.044Z

Oops I accidentally slipped and made it configurable on develop with g:conjure#client#clojure#nrepl#eval#print_function. Feel free to give that a go!

2020-07-26T15:45:44.044200Z

Thanks, I'll give it a go!

2020-07-26T16:04:57.044400Z

Thanks a bunch. I was able to get it to work with that configuration. I'll continue to investigate doing it with nrepl directly though, because I wouldn't want for you to add unnecessary configuration bloat if you don't have to!