Fork me on GitHub
#conjure
<
2020-04-29
>
Olical11:04:46

Okay, it probably needs some severe testing... but... I kinda did some black magic hackery, deleted a bunch of code and got a best of both worlds scenario for stdout / stderr output.

Olical11:04:27

So now if you (print ...) (no trailing newline) and flush, you'll see that output RIGHT away. No delay or batching. Then if you (println ...) something else it'll still end up on the end of that same line.

Olical11:04:41

The code is less complex and stateful than before but it works better and has no batching or delay to the output.

Olical11:04:05

@nate please try and break it when you have time πŸ˜„

Olical11:04:38

@dominicm Thanks for the nudge towards keeping it immediate, was worth the thought! It only took a morning and a coffee. Going to reward myself with a second one.

Olical11:04:04

It's so live you can animate a progress bar, hah! https://asciinema.org/a/kWZBUArB1q8hvavQl6pTxGkGJ

Olical12:04:24

Trimming the log will now avoid cutting forms in half at all costs. So if your log gets REALLY long, it'll always avoid cutting a form now. It used to try to but then sometimes give up if there wasn't a good cutting point. Now it'll let the log grow until it can cut it down safely between your eval results.

dominicm12:04:33

Don't worry, I'll keep inventing new features for you to do all the work on

πŸ˜‚ 1
Olical12:04:43

Aye aye, boss πŸ˜„

Olical13:04:31

Improved Deoplete support to make it actually async, blocking the Python process rather than your Neovim. Will do the same with CoC.

Olical13:04:52

(all of these things are on develop and ready for breaking.... I mean testing)

dave13:04:40

i use CoC and i didn't notice anything blocking

dave13:04:12

maybe it's just really fast?

Olical13:04:16

Yep, it's blocking but snappy right now πŸ˜…

Olical13:04:14

The blocking part relies on a thing in Neovim that allows events to continue in the background, it's just your input that gets slowed down. I'll make it completely async now.

πŸ’― 1
Olical13:04:27

Will see what I can do about asynccomplete (the vimscript one)

Olical13:04:58

So hard to know what parens are required and where I can put operators in JS.

Olical13:04:15

Also no idea how to get var args other than slicing around with arguments, maybe there's a less awful way these days.

Olical13:04:26

Have I told you before how much I dislike this language? πŸ˜…

Olical13:04:43

(you can tell when I'm tweaking the CoC support by my moaning)

Olical13:04:15

Note to future self: Parens are required in a while (!await ...) {

Olical13:04:33

Yeah, I expected something to exist but to only work in Chrome v247 on a Tuesday with some flag enabled.

Olical13:04:40

Maybe I'm wrong in a very good way!

Olical13:04:01

Published [email protected] which is truly async.

dave13:04:01

good idea to be paranoid about that πŸ™‚

Olical13:04:18

I assume CoC uses your local node version, so if it doesn't support async await I don't think coc-conjure will work :thinking_face: might need rewriting at some point to use plain old promises

Olical13:04:31

Which also won't work in some versions of node, so may need a promise shim at some point too?

Olical13:04:38

(I have NOT missed JavaScript)

dave13:04:00

it looks like async/await was added to node in node 8, which was released 2017-05-30

dave13:04:09

uncomfortably recent, in my opinion

Olical13:04:34

Yeah, I feel like it's just about okay but some people could be bitten by it πŸ˜•

dave13:04:29

on the other hand, you have to move forward at some point

dave13:04:56

i don't think there would be anything wrong with documenting that coc-conjure requires node 8+

Olical13:04:32

@matthew.newland I've changed the Deoplete and CoC completion support to be truly async, I didn't realise the method I mentioned before was blocking (although it allowed some events to continue in the background of Neovim which is nice) Deoplete now looks like this: https://github.com/Olical/conjure/blob/25b27d65d4ecb1fdf2f84d0b91ce067706211560/rplugin/python3/deoplete/sources/conjure.py And CoC like this: https://github.com/Olical/coc-conjure/blob/e34413be524a38a589a510b0d3eb6cd1195cb97a/index.js All you have to do is call completions-promise (as you have been) then call done? on the result until it's true with a delay between. With Python and Node I can pause execution before making another check, asynccomplete can't do this since it's in process. I'm under the impression you can implement a completer with a callback though? So if you want to get it fully async, all you need to do is work out how that callback based interface works and then have some vim timer (built in) call your check function repeatedly until the promise is done. Then give the result of calling close to the callback of asyncomplete.

Olical13:04:05

This isn't essential but it's the change you'd need to make to get it completely async. I have no idea how you use the callback interface for asyncomplete, I just read about it.

Olical13:04:20

Ah, I see. So you'd start by calling conjure.eval's completions-promise and capturing that result. Then you do some sort of timer loop (there's a function for this in nvim) to check conjure.promise's done? function until it returns true. Then you call asyncomplete#complete with the result of conjure.promise's close function. A bit like the three step one you had before.

The Continium15:04:57

Cheers @olical. I will take a look at your CR and your comments here.

dave13:04:15

i'm working on our integration tests repo now using the "eval at mark" feature. it's so good! and the HUD experience makes it so much better

Olical13:04:20

Yesss so glad to hear that! And now eval at mark doesn't flicker to the code it's evaluating, it all happens behind the scenes thanks to Lua land.

dharrigan14:04:33

Will there be a write up on how to get all the various parts to work nicely? i.e., coc + aysnc + neovim + conjure?

Olical14:04:51

Yup, either in wiki or blog posts

Olical14:04:57

More specific and guide-y

Olical14:04:09

I'm just trying to get all the docs there in :help for now, then build on that with more prose.

Olical14:04:45

Really though it's: Start regular CIDER nREPL (LOADS of resources out there for this), open Clojure file. Start typing.

Olical14:04:01

After you've installed coc + coc-conjure which is documented on the repo I think.

Olical14:04:09

Then it's just async by default. The magic should just happen.

Olical14:04:19

No config required (until you get annoyed at my defaults)

dharrigan14:04:23

I have this installed too clojure-vim/async-clj-omni

dharrigan14:04:29

as part of my current neovim setup

Olical14:04:32

Oh no, no need

dharrigan14:04:39

in the new one, or current one?

Olical14:04:42

Doesn't touch Conjure in anyway, it's already fully async

Olical14:04:44

Even the old one

Olical14:04:56

Both haven't required that, it's only fireplace I think?

dharrigan14:04:21

This is my clojure vim setup

dharrigan14:04:24

Plug 'Olical/conjure', { 'branch': 'master', 'do': 'bin/compile', 'for': 'clojure' }
Plug 'eraserhd/parinfer-rust', {'do': 'cargo build --release', 'for': 'clojure'}
Plug 'guns/vim-clojure-highlight', {'for': 'clojure'}
Plug 'guns/vim-clojure-static', {'for': 'clojure'}
Plug 'guns/vim-sexp', {'for': 'clojure'}
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'tpope/vim-sexp-mappings-for-regular-people', {'for': 'clojure'}

dave14:04:54

this is almost exactly my clojure setup!

dave14:04:17

i don't claim to 100% know what i'm doing, but it's nice to know that someone else has independently arrived at the same conclusion πŸ™‚

dave14:04:55

the only difference in my setup is that i don't use the vim-clojure-highlight package

dharrigan15:04:20

I feel nice that someone else too has arrived at nearly the same setup πŸ™‚

Olical14:04:31

> removing... dd is the best Vim command

Olical14:04:51

You won't need to bin/compile on develop either πŸ˜„ it just works after install

Olical14:04:02

But yeah, similar to mine! Except I only have sexp, not parinfer

Olical14:04:37

And then you need to configure coc to use https://github.com/jlesquembre/coc-conjure (I've published the dev version as coc-conjure-olical)

dharrigan14:04:30

Do I need that plugin (coc-conjure) for the current version of conjure?

dharrigan14:04:56

CoC seems to work atm, since I'm using clojure-lsp

Olical14:04:16

You don't need it, but if you want CoC to complete over your Conjure connection you need to install it.

Olical14:04:27

The one on the main master branch will work with the current release of Conjure.

Olical14:04:37

My coc-conjure-olical fork is for the rewrite.

Olical14:04:56

If LSP is working for you though stick with it!

Olical14:04:04

If it ain't broke...

Olical14:04:15

I just like my completions coming from the running live environment, not files.

dharrigan14:04:07

It's all still a black magic art about which plugin to isntall and what mappings/vars to set for them all to work

dharrigan14:04:14

well, I suppose, that's because vim isn't an IDE πŸ™‚

Olical14:04:55

So all you should need is Conjure, then you get omnicomplete. You just need to add further plugins if you want async complete as you type since Vim doesn't support that out of the box.

Olical14:04:06

Shouldn't need any mappings etc :thinking_face:

Olical14:04:04

Is there something in the Conjure specific stuff that's highly confusing then? Or like Clojure in Neovim in general?

Olical14:04:29

Because once Conjure (develop) is out I'll write up a post for how I set up Neovim for Conjure from scratch maybe :thinking_face:

dharrigan14:04:17

It's more Clojure and Neovim. Of course, my chosen plugin is Conjure, so it is related. it's FOMO, perhaps I'm not having the most optimal experience because I've got a plugin enabled that I don't need or a plugin that I'm missing...

Olical14:04:32

Fair enough! I think moving from things like fireplace means you get stuck with things like clojure-vim/async-clj-omni. I don't think you need much at all, the baseline is quite simple, it's what you want to add later that gets interesting. I'll write about it at some point to try and clear some things up πŸ™‚

Olical14:04:44

Almost finished updating the asyncomplete plugin by @matthew.newland to be completely async. I gave the wrong instructions before. So that means you'll have three good options for complete async completion.

Olical14:04:41

@matthew.newland I did the fully async changes for you https://github.com/thecontinium/asyncomplete-conjure.vim/pull/1 πŸ˜„

Olical14:04:42

Alright, my brain is pretty fried now, time for some video games and water πŸ˜… more progress! Next task on my list is "release", so if anyone can break the new Conjure, please let me know! πŸ™‚

dharrigan15:04:01

I do have coc-conjure installed

dharrigan15:04:15

let g:coc_global_extensions = ['coc-conjure', 'coc-json', 'coc-yaml', 'coc-dictionary']

dharrigan15:04:28

I forgot that coc manages it's own extensions itself

nate16:04:21

@olical just tried out latest from develop and string printing still works well!

nate16:04:34

I love the idea of a progress bar, going to use that

Olical16:04:45

Wonderful! πŸ˜„ (considering how much code I changed I'm very pleasantly surprised everything worked so well)

tetriscodes18:04:29

Where can I get docs on connecting Conjure to Shadow-cljs

Olical18:04:44

I replied in the shadow-cljs thread πŸ™‚

Olical18:04:51

Can reply here though!

Olical18:04:25

Basically shadow + prepl never worked well and requires a LOT of work to get it working properly. I've instead rewritten Conjure and based it on nREPL. It works better in basically every way, easier to start and use too imho.

Olical18:04:52

If you start a shadow-cljs server and open a CLJS file with the new Conjure (develop branch) installed, it'll automatically connect.

Olical18:04:15

Then you can use :ConjureShadowSelect my-app and just start evaluating.

Olical19:04:06

https://github.com/Olical/conjure/tree/develop should have all the info you need. Add it as a plugin (no bin/compile required anymore!), start a shadow-cljs server with nREPL (that's documented on the shadow site), open a ClojureScript file, run :ConjureShadowSelect my-app-name, evaluate forms with <localleader>ee and get autocompletion! πŸ˜„

Olical19:04:24

:help conjure and :help conjure-client-clojure-nrepl for all the keys and config you can do.

tetriscodes19:04:56

Did you have to drop support for prepl?

tetriscodes19:04:30

ah, I see your note about a rewrite

Olical19:04:38

Yes, they are COMPLETELY different things. nREPL + (optional) CIDER saves me about 6 months - 2 years worth of work πŸ˜…

Olical19:04:00

I'm going to add a prepl based Clojure module you can swap in eventually though. It won't be as smart but it'll let you do some useful things!

tetriscodes19:04:29

Whats the reason for dropping prepl? Not enough support?

Olical19:04:33

The new Conjure is a framework of "I want to run some code" with modules that handle how that happens. Which means it'll support multiple network REPL systems and languages.

Olical19:04:42

ClojureScript and even Clojure support was awful and I couldn't fix it.

Olical19:04:50

I still have patches waiting for merge, I sent them about a year ago

tetriscodes19:04:02

Well, this is hands down the best clojure setup I’ve ever used

Olical19:04:02

It's a shame, but it's just practical

Olical19:04:33

Well thank you! I really hope you'll like the rewrite more, it's just more of the same. Sped up, stream lined, extra JVM removed, more languages supported.

Olical19:04:55

I would highly recommend using the new one since I'm going to be releasing it within a week or so πŸ˜„

tetriscodes19:04:35

I switched. It works. Thank you so much.

πŸŽ‰ 1
Olical19:04:44

prepl is a lovely concept (built in socket REPL for tools) it's just so inconsistent and broken between CLJS and CLJ. There's no way I could ever get completion working in CLJS for example, the new Conjure has it working out of the box.

Olical19:04:22

I was on the edge of writing my own prepl as a dependency you had to add, then we're back to nREPL and reinventing the wheel. So I jumped on the bandwagon and the bandwagon is good.

Olical19:04:53

Just ask if you have any questions! Trying to get people up and running and giving me feedback on the develop UX πŸ™‚

tetriscodes20:04:40

Autocompletion not working, any idea? <C-x><C-o> isn’t working either

tetriscodes20:04:12

worked fine on the master branch

Olical20:04:30

Hmm, on shadow-cljs?

Olical20:04:54

If it's regular Clojure, you need to add the CIDER middleware to get all the goodies like go-to-def and autocompletion at the moment.

Olical20:04:00

Shadow comes with it I think.

tetriscodes20:04:35

I added cider-nrepl to deps.edn, and go-to-def works but not completion

Olical20:04:52

Oh interesting! That sucks :thinking_face: and this is regular Clojure, not ClojureScript?

tetriscodes20:04:06

CLojurescript

Olical20:04:08

(I don't think anyone else has encountered that yet, so I'm trying to think of what could interfere with it)

tetriscodes20:04:18

Seems I need to configure the middleware in shadow

tetriscodes20:04:37

if it works i can submit a PR to you with an example

Olical20:04:05

Sure, of course! I don't have anything shadow related in my repo though other than test code.

Olical20:04:16

It's what I use to test shadow support and it's working great

Olical21:04:51

There's an update coming for nREPL (without CIDER) that's going to enable simple completion without the middleware. So that'll be fun!

Olical21:04:10

We get to benefit from all the work on nREPL and CIDER that all of the tool authors contribute. Should be good πŸ˜„

tetriscodes18:04:42

Trying to get a browser-repl connected in Vim.

nate19:04:09

oooo, interesting workflow that the new conjure allows. I'm working on transforming data from one big map to another. I have the original data in one conjure log split (that doesn't scroll because my cursor is not at the bottom) and have another log split to see the results of my function calls (that does scroll). Then I can reference the old while making the new.

Olical19:04:26

Yessss, working as intended and I'm very happy to hear πŸ˜„

Olical19:04:43

I wanted it to let you pin things you're working with while still working on new data