Fork me on GitHub
#cider
<
2022-03-16
>
Charles Comstock03:03:05

So I am curious, when using invoking cljr-slash for ns suggestions in a cljc file, it prompts to inquire if the recommended ns should be from the cljs or cljc set. I wonder if that can provided as annotation on the source for a completion framework like counsel. Same as variable / fn completions are annotated, but instead show if whether or not the ns recommendation is from the cljs or clj set or both. Has anyone else explored that approach, or is there some technical limitation I'm not considering?

vemv05:03:43

All cljr prompts are done https://github.com/clojure-emacs/clj-refactor.el/blob/f368c56c83843396b160440f472a661a3b639862/clj-refactor.el#L2291-L2300. Note that it has a completing-read call. One can instead place there his favorite completion helper e.g. ido-completing-read or ivy-completing-read . I accomplish by using a local fork. Not sure if Emacs is supposed to have a generic way of customizing completing-read without altering sources. If this sounds like what you want, PR certainly welcome, it's just extracting a function to a defcustom :)

Charles Comstock17:03:00

I think the issue here is that before it even reaches that completing-read call for the candidates it goes through: https://github.com/clojure-emacs/clj-refactor.el/blob/f368c56c83843396b160440f472a661a3b639862/clj-refactor.el#L1928-L1940. I think my question is if instead the completing read call could include both clj and cljs suggested namespaces in one shot, but annotate the source?

Charles Comstock17:03:21

Anyway thanks, I think I might know how to address this, I'll see if I can't scratch the itch myself soon.

vemv20:03:00

Yeah I'd implement this as two separate features/defcustoms that can be composed together (or not): • merge clj + cljs options ◦ I think this makes a lot of sense on its own. Often the two sets are similar enough, that a distinction just means more user friction • annotate options Both are things that are better done "client side" (clj-refactor, not refactor-nrepl) so hacking seems at hand. Let me know how it goes :)

Charles Comstock20:03:00

Thanks! Will do!

vemv20:03:42

As a quick thought, merging has some danger in case of cljs "string requires" which could mean that we're inserting such a require for the JVM clj code path, which is syntactically invalid

Charles Comstock20:03:08

Ah gotcha, yea that's the sort of domain gotcha I wasn't quite aware of but assumed lurked in the depths. Is that annotated at all in the info coming back from the middleware? Ie is there anything in the system that is already aware of that edge case?

Charles Comstock20:03:38

Also I see from cljr--get-aliases-from-middleware that the hash returns either clj and cljs aliases, does it or should it also return aliases used in cljc files? Would that help address this? Anyway I'll play with it without changing what the middleware returns for now, but I wonder if that would help.

vemv20:03:54

in all cases refactor-nrepl returns a map with :clj and :cljs keys for a .clj file, :clj will be filled and :cljs will be empty vice versa for a .cljs file

vemv20:03:02

for a .cljc file, :clj will have only the libspecs for the :clj code path (i.e. those that don't go through :cljs reader conditionals) :cljs will have only the libspecs for the :cljs code path (i.e. those that don't go through :clj reader conditionals)

vemv20:03:56

so, in a way it's already handled for you: if a libspec is only present in the :cljs set, then you can annotate it with "cljs only" So the user will know that, and the danger of inserting invalid code will be minimal (i.e. the user won't do something stupid :) )

Charles Comstock20:03:51

Gotcha, alright I will explore that. As an aside on development, is there a nice way to trick an elisp buffer to use a particular cider connection and bypass the cljr--assert-middleware guard for cider-connected-p?

vemv21:03:14

> is there a nice way to trick an elisp buffer to use a particular cider connection That seems sesman stuff which I know very little about > bypass the cljr--assert-middleware guard for cider-connected-p You can (defun cljr--assert-middleware ()) in your init.el, it will override the original

Charles Comstock21:03:02

I guess, but the buffer won't know which connection to use, which is I guess more what I was looking for. Anyway, thanks for the help, was just hoping there was a quick trick to allow eval in the elisp buffer instead of defining a helper interactive function to run from the cider connected buffer, but I think the latter will help explore better anyway.

ahungry03:03:48

I've been away from cljs for some time (last time I tinkered with shadow-cljs was ~3 years ago). I'm trying to follow set up guides for both fulcro and re-frame, and I'm hitting a dead-end in both scenarios when it comes to "Having no JS environment" (even if I ensure I visit something like localhost:8200 before trying repl buffer evaluation). If I change from build-id :main or :app to browser, I can get a successful repl call to something like (js/alert 1) to work, but can't load any files from my project template (cljs) in repl. Also, trying a simple thing like cider-eval-defun-at-point appears to do nothing at all (no error, warning, info or side effect) - it appears it isn't trying to send to the cljs repl at all. Lastly, if I try to connect a clj repl while the cljs one is open (or vice-versa) it complains and ask if I want a sibling connection instead. Are there any modern step-by-step guides for emacs+cider+cljs = SPA? I may try figwheel-main next, to avoid the shadow-cljs stuff...

lilactown17:03:08

sounds like you're using emacs & cider

lilactown17:03:31

how are you connecting to the running app?

ahungry01:03:24

I was able to get it working with re-frame, I just had to wait awhile for the js to be present in browser (it was 404ing prior to compiling)

ahungry01:03:44

I guess initial load was taking longer and I was being impatient 😄