Olical / conjure

Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
https://conjure.oli.me.uk
The Unlicense
1.73k stars 109 forks source link

Overhaul stdio based clients #365

Open Olical opened 2 years ago

Olical commented 2 years ago

It's obvious that the various clients that aren't Clojure over nREPL are far more fiddly and brittle. Especially those that try to work over stdio.

The solution to this, I think, is to write a new stdio transport from scratch that's FAR more flexible. It should allow users to start and stop processes easily as well as provide MANY hooks into how it parses and understands the output.

The idea would be to remove the idea of "all we need is a regular expression :)" and instead face the reality: Each REPL is different, we do not have enough information since it's intended for humans, we NEED to use heuristics and hints that are unique to each REPL. (by hints, I mean even things like indentation levels to try to distinguish between stdout / stderr and eval results)

So a hypothetical future stdio client using this system (because it'll be reusable!) will be able to configure it with various functions that get given streams of lines (maybe one at a time) and they can respond with state and context to try to understand the output. We can use timeouts to confirm that the REPL prompt is back and the evaluation is complete.

Basically rather than assuming we can understand the output with a regex we should allow each client to parse the lines and make sense of them as they see fit with functions.

This issue is a placeholder so I don't forget to do this... but I'd like to make stdio clients feel as close to first class as I can. Even if it will never be as good as a proper nREPL server, I'd like to make the foundation solid for building more interesting interactions.

russtoku commented 1 year ago

See conjure.remote.stdio2: Rebuilding the foundation of stdio support for what things might look like.