-
-
Notifications
You must be signed in to change notification settings - Fork 653
Description
I had a long discussion with @cemerick about alternative approaches for autocomplete in cljs w/nrepl.
The driving concerns:
The piggieback middleware only adds the clojurescript compiler environment to the session, on the main session.
nrepl-complete can only access the compiler environment if it's been added by piggieback. See https://github.com/gtrak/nrepl-complete/blob/master/src/nrepl_complete/middleware.clj#L9 and https://github.com/cemerick/piggieback/blob/master/src/cemerick/piggieback.clj#L238
As I understand it, the drive for a separate tooling session is to avoid botching env variables (*1 *e, etc.) or blocking user "eval". Nrepl complete uses the "complete" op, and it can never mess up those env vars.
I don't see a way to associate the needed environment of the main session to the tooling session cleanly.
Assuming we stick with the tooling session, I'd need a way to grab the needed data through a global mechanism, which would require knowing the ID of the main session. I don't think it makes sense to pass the ID of the main session into every op, like a :target-session key or something. That would be painful at scale. If there were a general way to associate sessions, I'm not sure why it would conceptually make sense.
This hasn't been a problem before because multiple clojure nrepl sessions are coupled to each other implicitly through JVM state. CLJS and piggieback break that assumption, and in general, we want decoupling and removal of assumptions from the client.
A nrepl op middleware approach would remove the burden of bookkeeping from the client to the extent that they're implemented.