This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-24
Channels
- # announcements (39)
- # aws (4)
- # babashka (18)
- # beginners (32)
- # biff (10)
- # calva (22)
- # clj-kondo (11)
- # clj-on-windows (2)
- # cljs-dev (20)
- # clojure (31)
- # clojure-europe (130)
- # clojure-norway (21)
- # clojure-spec (24)
- # clojure-uk (17)
- # clojured (2)
- # clojurescript (6)
- # conjure (1)
- # core-async (5)
- # cursive (11)
- # datalevin (1)
- # datomic (9)
- # emacs (24)
- # figwheel-main (42)
- # fulcro (6)
- # gratitude (6)
- # honeysql (8)
- # juxt (16)
- # kaocha (6)
- # lsp (235)
- # malli (2)
- # nbb (7)
- # off-topic (23)
- # other-languages (24)
- # pedestal (7)
- # reitit (6)
- # sci (1)
- # shadow-cljs (21)
- # tools-build (22)
- # tools-deps (57)
- # vim (24)
(defun mm/cider-jack-in-with-an-alias-from-deps ()
(interactive)
(if-let* ((root (project-root (project-current t)))
(_ (file-exists-p (expand-file-name "deps.edn" root))))
(let* ((default-directory root)
(my-alias
(completing-read
"Cider jack in with alias: "
(read-from-string
(shell-command-to-string
(format "bb -e '%s'" (princ '(->> (slurp "\"deps.edn\"") read-string :aliases keys (map name))))))))
(cider-clojure-cli-aliases
(concat
cider-clojure-cli-aliases ":" my-alias)))
(call-interactively #'cider-jack-in-clj))
(user-error "no deps.edn file in project")))
I can't be the only one who wanted thisThat could be improved to also take into account the other aliases available (user level for instance).
clj -X:deps aliases
but it's not very data oriented (if needed, would be open to an edn output option too)
I remembered I had used it but didn’t find it in clj --help
so I got a bit confused
Programs provided by :deps alias:
-X:deps mvn-install Install a maven jar to the local repository cache
-X:deps git-resolve-tags Resolve git coord tags to shas and update deps.edn
-X:deps find-versions Find available versions of a library
-X:deps prep Prepare all unprepped libs in the dep tree
yeah, some of the docs are still lagging the newer stuff
(just use a prefix when jacking-in will let you edit the command as well). Or stuffing all of the stuff cider wants into a profile (easily copy from the startup command in the top of the repl) and then just use terminal to start your process clj -M:dev:stuff:cider/nrepl
and off you go
It's just an extra RET when you don't edit the aliases and otherwise you're free to add whatever
.dir-locals.el works fine for my workflow. I don't understand / relate to a use case for this. Are people frequently changing their aliases that it needs some picker? Is it because lots of different projects are being used and they all use different alias names ? Does this approach have to rely on external tools that may not be installed?
for me the use case is when I have build or test aliases and I want to repl. If I have a dev alias it is covered with .dir-locals
Is there a reason the test and build aliases cannot be included in the .dir-locals.el
configuration and loaded into the REPL on startup?
Do they add significant resource overhead?
I typically include the dev and test aliases in .dir-locals.el
so I can run the cider-test runner (although I often use kaocha in watch mode in a separate terminal as well)
I usually build from the command line (assuming I need to manually build at all - build is mostly done by continuous integration server or docker if its a local complex (AWS) environment)
Maybe I am missing something...
I was curious to know if there were common cases I wasn't aware of. I am aware Calva for VS Code has an alias picker, perhaps because the VS Code doesn't have an equivalent of a .dir-locals.el. Maybe a picker is useful for occasional user level aliases, although I have too many aliases for a checkbox style picker, unless it's coupled with a completion selector - although again it's probably easier to edit the .dir-locals.el