practicalli / clojure-cli-config

User aliases and Clojure CLI configuration for deps.edn based projects

Home Page:https://practical.li/clojure/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support Clerk as inspector ?

behrica opened this issue · comments

An alias like below starts CIDER-nREPL and opens Clerk and starts its "tap inspector", which is conceptually the same as portal and reveal, just powered by Clerk.
After this any "tapped" value is rendered in Browser.

I noticed an "issue", by "tap>" not giving the control back to the repl...
This does not happen, if you connect Emacs or an other nRepl client.

Not sure, what the root cause of this is

:inspect/clerk
  {:extra-deps {io.github.nextjournal/clerk {:mvn/version "0.15.957"}
                nrepl/nrepl                   {:mvn/version "1.0.0"}
                cider/cider-nrepl             {:mvn/version "0.28.7"}
                refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}}
   :main-opts ["-e" "(require '[nextjournal.clerk])(nextjournal.clerk/show! 'nextjournal.clerk.tap)(nextjournal.clerk/serve! {:browse? true})"
               "-m" "nrepl.cmdline"
               "--interactive"
               "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}

Thank you, this is very interesting. I would like to include more with Clerk, so will try this out tomorrow.

My own preference is to have the loading of clerk libs and starting clerk in a custom user namespace, so rather than the -e option

"-e" "(require '[nextjournal.clerk])(nextjournal.clerk/show! 'nextjournal.clerk.tap)(nextjournal.clerk/serve! {:browse? true}

I would create a dev/user.clj file would in the project, e.g.

(ns user
 (require 
   [nextjournal.clerk]))

(nextjournal.clerk/show! 'nextjournal.clerk.tap)(nextjournal.clerk/serve! {:browse? true})

I do not know if this approach would make any difference to the minor issue of tap> not returning control to the repl

I will try both approaches over the coming days and see if there are any difference (I assume it's unlikely).

I'll also try without refactor-nrepl as I havet used clj-refactor for quite a while
Thanks again

I tried as well to have "editor commands" which send the above code:
This is an other workable approach.

I do agree that clojure cli does not really have a foreseen way via commandline to send "initialisation code" (before a repl starts), It has "either repl" or "run code to finish" . The "-e" and start repl is a bit of a hack.

:repl/clerk has been added as an initial design for an alias, using the configuration in the original post.

commit: 6b0649a

I've added a comment to highlight its alpha design and have not yet added documentation or an entry to the readme. This will be added once the design is stable.