-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom cider-ns-refresh-fn
#849
Comments
Thanks! Giving it some thought, I wouldn't want to add conditionals to https://github.com/clojure-emacs/cider-nrepl/blob/9aea519b87430c3a26cd146417dd84c33bb14676/src/cider/nrepl/middleware/refresh.clj . It's also, unfortunately, not as simple as adding a So I'd suggest that you implement a similar namespace based on the new lib. What users would customize would be the nREPL ops. Currently we accept:
So users in cider.el would instead specify:
...that's a small change that would make a nice small PR into cider.el. You could then have the custom middleware in your classpath for a while (as small bugs are reasonable to expect in the integration or clj-reload). After a couple weeks, we could make it official and integrate it here. SGTY? Cheers - V |
I'm not sure if that's prudent, as there's also #710 and I was thinking of a prefix like |
Yes good call, |
That'd be fine by me as well. Depends on what we agree to do for the global package prefix, as I think we already have ops namespaced with |
I'm working on this and hope to have a PR we can look at soon. A questions please: Is there a way already in cider-nrepl codebase to get the src-dirs that clojure is using? |
That's great to hear! We use
clojure.tools.namespace.repl/set-refresh-dirs (there are tools.namespace users that don't, but then again they easily get into trouble so it's not a supported workflow)
|
So is the expectation for tools.namespace that users set those dirs in their project directly? I was testing cld-reload and it requires the dirs to be set in advance, otherwise reload won't work.
|
Yes, there's normally a The pattern seems similar in clj-reload |
I'm guessing those can be inferred on CIDER's end. I have to check the code for c.t.n., but I don't see in the user docs we wrote anything about a manual setup needed by the users https://docs.cider.mx/cider/usage/misc_features.html#reloading-code |
Maybe we should! I've saved the item (without explicit refresh dirs, it/we can try to load undesired code e.g. stuff under |
Yeah, maybe the docs need some improvement. I haven't used this functionality in a while, so my memory there is a bit fuzzy. |
I was actually surprised about the source mentioning the dirs needed to be set for tools.namespace. I've been using the refresh functionality for a while in a couple of different projects and I've never set the dirs. Which I guess leads me to the next point: this repo carries its own tools.namespace dependency. I understand mranderson takes cares of scoped dependencies. But it also means that the refresh functionality work without the user installing tools.namespace. A CIDER user right now is able to use refresh without any change to their project. But since clj-reload need the init, if cider-nrepl does not carry its own clj-reload dep, and does not infer the src dirs necessary for init, then the clj-reload functionality will not work without the user changing their project. |
I wouldn't characterize it as changing it as much as "setting it up". It's not different in that regard from tools.namespace. I understand that it can work without the setup, but it's something I know to be problematic (I can say this as a long-time t.n user) Btw, we'd be ok with shipping a mranderson-ized |
Proposed a change to cli-reload that would mimic the tools.namespace behaviour: tonsky/clj-reload#4. Can be done in cider-nrepl instead, but I thought maybe it'd be desirable overall. |
Opened #850 as a draft implementation just so we can start talking about it and sort out the names. |
I'd like to use https://tonsky.me/blog/clj-reload/ instead of
clojure.tools.namespace
to refresh my code. The main thing I like it in is howdefonce
just works, and I don't have to fiddle around withclojure.tools.namespace
in my source code.I see there's
cider-ns-refresh-before-fn
andcider-ns-refresh-after-fn
in the docs, but there's no configurablecider-ns-refresh-fn
at least in those docs. So that seemed like a nice hook point.I'd be interested in making a PR for this approach, or some other approach you feel is better. Thanks for all the good work!
The text was updated successfully, but these errors were encountered: