Skip to content

non-eval ops shouldn't use tooling session, now specifically "complete" for the sake of nrepl-complete middleware #460

@gtrak

Description

@gtrak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions