nbb icon indicating copy to clipboard operation
nbb copied to clipboard

Expose the nrepl-server API

Open jaidetree opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe.

  • The nrepl-server is very noisy echoing everything sent to it and every response message. If the nrepl-server's API is exposed, we could configure it more to suit our needs as users.

  • When working on a project it seems I forget to evaluate the whole buffer a lot before starting to evaluate forms. Usually this results in an error of some kind about a function not being defined. Exposing more the nrepl-server API would allow users such as myself to create a start script that imports a project's entrypoint so that it's ready to go.

Describe the solution you'd like

(require '[nbb.nrepl-server :as nrepl])

(require '[my-project.core :as proj])

(proj/main)
(nrepl/start {:port 3030
              :log-level :warn})

Describe alternatives you've considered

I think in this case there are not many alternatives, seems a good chunk of the nrepl-server needed to be ported to be compatible with sci and\or cljs.

Additional context

We discussed this a bit in slack. Seems most of the nrepl-server code was initially drafted by another person to get to a working point. Sounds like you want to take a step back and think about how the nrepl-server fits into the project and what the long-term vision for the dx is.

jaidetree avatar Feb 22 '22 08:02 jaidetree

Presumably this is the linked Slack conversation referred to above. Anything happen since then?

I've come to this issue because I can't connect to the nrepl-server when it's in a Docker container. Although I don't know the exact issue, it could be the one described here: https://www.fbrs.io/nrepl-docker/ in which case a --bind 0.0.0.0 argument may be necessary (or equivalent if this is a bespoke nrepl).

dmg46664 avatar May 08 '22 15:05 dmg46664

@dmg46664 I think in addition to :port we could also accept a :host argument on the command line. This should be an easy change. PR welcome.

borkdude avatar May 08 '22 16:05 borkdude

Just adding a comment here for completeness https://github.com/babashka/nbb/pull/186

dmg46664 avatar May 10 '22 18:05 dmg46664