I would love to completely switch from Cursive’s console repl to portal but I can’t get the portal nrepl middleware to work. I have set up an .nrepl.edn file with contents
{:middleware [portal.nrepl/wrap-portal]}
My user.clj contains the following:
(defonce portal* (do
(add-tap portal.api/submit)
(portal.api/open {})))
When I start a repl, Portal opens and tap> are displayed in it but Cursive namespace and form evaluation results do not get displayed in Portal. I know that .nrepl.edn file is getting picked up because if I add garbage middleware to it, the repl does not start.As a heuristic to avoid tapping tooling evals,https://github.com/djblue/portal/blob/master/src/portal/nrepl.clj#L63 will only tap nrepl eval requests with a :file . I think you might be running into this if you are trying to eval from the repl window instead of a file.
I assume this would work if you eval code from the editor directly, but I haven't tested it
I’m not familiar with middleware and I don’t know how Cursive sends evaluation requests to nrepl. What I can say is that neither Cursive’s “Load File in REPL” nor “Send form to REPL” commands show up in Portal
Eval-ing code directly from the editor is “Send form to REPL” and that does not end up in Portal.
Is there a debug option to turn off portal’s filtering heuristics?
Not currently, nrepl middleware tend to be a bit more difficult to make configurable
Yeah, I can see that. Maybe a jvm -D option?
I'll see if I can getting it working out of the box for cursive users. For now, I think it would be easiest to vendor the portal.nrepl middleware since it's only a single file and remove the :file requirement
Thanks!
^{:clojure.core/eval-file \"/Users/abadahdah/repos/portal/src/portal/nrepl.clj\" :line 57 :column 1} (+ 1 2 3) cursive seems to be doing an interesting thing for eval 🤔
How does that compare to other editors?
the nrepl protocol has explicit fields in the request map for :file, :line and :column
ah
The metadata approach has issues with values that don't support metadata 😬
Yeah, what happens with you try to eval a string?
The nrepl request looks roughly like:
{:ns "portal.nrepl",
:op "eval",
:id "213087fb-a648-418c-9ecf-945290605ef2",
:code "\"hello\""}The difficult bit here is that cursive also submits tooling request via eval
Is it worth raising the issue in #cursive?
Might be worth it. If cursive updated the request map to include the file info, it should be backwards compatible and portal.nrepl would work with the existing heuristic
Cool. I’ll raise the issue in #cursive and reference this thread