This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-24
Channels
- # announcements (5)
- # aws (24)
- # babashka (41)
- # beginners (130)
- # bristol-clojurians (2)
- # calva (39)
- # chlorine-clover (64)
- # cider (30)
- # clojure (202)
- # clojure-belgium (1)
- # clojure-dev (99)
- # clojure-europe (5)
- # clojure-hungary (4)
- # clojure-italy (10)
- # clojure-losangeles (8)
- # clojure-nl (11)
- # clojure-norway (6)
- # clojure-spec (7)
- # clojure-uk (12)
- # clojurescript (52)
- # core-typed (26)
- # cursive (19)
- # data-science (19)
- # datomic (19)
- # duct (10)
- # emacs (17)
- # fulcro (22)
- # graalvm (11)
- # jobs (3)
- # kaocha (28)
- # leiningen (6)
- # lumo (2)
- # malli (10)
- # nrepl (2)
- # off-topic (23)
- # pathom (2)
- # pedestal (7)
- # re-frame (3)
- # reagent (30)
- # reitit (2)
- # remote-jobs (2)
- # shadow-cljs (77)
- # sql (10)
- # test-check (22)
- # tools-deps (37)
- # vscode (1)
- # yada (3)
Hi! I need to add a single additional middleware to the way cider-jack-in
works. I'm reading this: https://docs.cider.mx/cider/basics/up_and_running.html#_auto_injecting_dependencies
I already have a cider-clojure-cli-global-options
customization on a .dir-locals.el file on my project that looks something like: -A:alias1:alias2:etc
but I 'm not sure if there's a way to modify that option or some other to add something the the list of middleware cider jack in uses.
Specifically I'm trying to add nrepl-rebl to the middleware that is added when cider-jack-in
is called
This seems promissing:
This is why long term logs rock:
copied here for convenience in case someone finds this log:
; .dir-locals.el
((clojure-mode
(cider-clojure-cli-global-options . "-A:dev")
(cider-jack-in-nrepl-middlewares . ("nrebl.middleware/wrap-nrebl"
"cider.nrepl/cider-middleware"))))
as it turns out, if that list is defined, it replaces the standard list of whatever version of cider
is being used
which is a bit inconvenient because I need to manually add the cider middleware and other stuff like the clj-refactor middleware, which previously just worked
this is what the list looks like before overriding it:
(("refactor-nrepl.middleware/wrap-refactor" :predicate cljr--inject-middleware-p) "cider.nrepl/cider-middleware")
unfortunately I don't know how to append to that list instead of replacing it
So I'm just gonna copy-paste it on my .dir-locals.el and add the rebl-wrapper ref for now
ohhhhh it worked
((nil
(cider-jack-in-nrepl-middlewares . ("nrepl-rebl.core/wrap-rebl"
("refactor-nrepl.middleware/wrap-refactor"
:predicate cljr--inject-middleware-p)
"cider.nrepl/cider-middleware"))
(cider-clojure-cli-global-options . "-A:cider:xml:rebl")
(cider-default-cljs-repl . figwheel-main)
(cider-figwheel-main-default-options . ":dev")))
my final setup
now I have both REBL and clj-refactor and the cider middleware all working together yaaaay 🙂
one thing you could do is put all that in a function. (let ((.. ..)) (cider-jack-in-cljs))
interesting dpsutton. I have no idea how to do that though haha. I guess it will eventually come time for me to finally learn elisp 😛
I suspect there might be a way using add-hook-###-### since that's what clj-refactor does
https://github.com/clojure-emacs/clj-refactor.el/blob/master/clj-refactor.el#L4118-L4127
You might open a ticket about this, so we can discuss how we can improve this setup and the documentation surrounding it.
Generally it’s better to use add-to-list
than to just override the middleware config - e.g. https://github.com/clojure-emacs/sayid/blob/master/src/el/sayid.el#L151
Of course, this was meant mostly for extensions to plug-in something extra. For end users it might also make sense to have an extra config that’s just gets appended to the “core” list.
thanks bozhidar! will collect my logs about this issue when I get home and put them on a cider issue.