cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
bozhidar 2020-11-12T07:06:54.441300Z

@jmckitrick Where do you get this?

jmckitrick 2020-11-12T10:00:05.442800Z

I started a project with tools. deps, and it's dev entrypoint starts shadow. I called cider-connect-to-cljs and followed the prompts, and that keyword was printed out in the output text of the repl right before the prompt appeared. I'm about to do more experimentation now

jmckitrick 2020-11-12T10:00:17.443Z

@bozhidar ☝️:skin-tone-2:

bozhidar 2020-11-12T10:03:59.443700Z

Got it. I guess it's something coming from shadow, as it's certainly not coming from CIDER.

bozhidar 2020-11-12T10:04:18.444100Z

Probably cider-nrepl is not on your classpath or something like this.

jmckitrick 2020-11-12T10:05:10.444300Z

Yes, this is my first time trying to connect cider to a non-trivial tools.deps project with shadow.

jmckitrick 2020-11-12T10:05:23.444500Z

Did you get my recent email? 🙂

jmckitrick 2020-11-12T12:53:56.452800Z

@bozhidar I landed a full-time Clojure gig, so I'm finally in a position to make some CIDER contributions. I think I emailed you a question about one feature I would work on... IF I can get my new project to connect CIDER to both repls.

bozhidar 2020-11-14T11:39:38.495300Z

Yeah, I did, but I've had a couple of very busy weeks and I'm a bit behind on my email responses. Sorry about that!

jmckitrick 2020-11-16T11:25:19.016Z

NP... anyway, I am 100% up and running and ready to help. No more excuses.

jmckitrick 2020-11-16T11:26:23.016200Z

Is it still the best course to pick a project and look for low-hanging fruit issues? Or is there another approach you'd suggest?

jmckitrick 2020-11-16T11:26:40.016400Z

I'm also decent at writing and proofreading docs.

jmckitrick 2020-11-17T17:32:09.019100Z

@bozhidar I saw a 'todo' for switching between clj and cljs connections, IIRC. Would that be a good feature to tackle?

bozhidar 2020-11-18T07:55:32.020200Z

> Is it still the best course to pick a project and look for low-hanging fruit issues? Or is there another approach you'd suggest? Yeah, definitely.

bozhidar 2020-11-18T07:56:17.020400Z

> @bozhidar I saw a 'todo' for switching between clj and cljs connections, IIRC. Would that be a good feature to tackle? Totally up to you. Generally it's best to work on things that you perceive to be valuable yourself.

jmckitrick 2020-11-18T13:43:56.020800Z

@bozhidar ok, I found it. cider-repl-switch-to-other. I want this feature! I see it has a FIXME. How can I help with it?

jmckitrick 2020-11-18T13:51:11.021Z

It mentions we need to implement cycling as session can hold more than 2 REPLs

bozhidar 2020-11-18T19:49:41.021500Z

Sure.

jmckitrick 2020-11-18T20:49:39.028800Z

So.. if you'd point me in the right direction, I'll try to make that happen. Any existing examples of a similar 'cycling' anywhere else?

Jim Newton 2020-11-12T09:25:54.442Z

what is the correct way to enable flycheck-mode on .clj files when using cider? Do I need to make this based on the .clj extension, or do I need to make it based on cider mode? Is this a cider thing or an emacs thing?

Jim Newton 2020-11-12T09:29:54.442700Z

do I want something like this in my .emacs file? (add-hook 'cider-mode-hook 'flycheck-mode)

bozhidar 2020-11-12T10:02:50.443300Z

I just enable it globally.

bozhidar 2020-11-14T11:38:59.495100Z

It defers to whatever linters are configured for the underlying major mode (or nothing).

Jim Newton 2020-11-12T11:23:00.444700Z

interesting, what does that do in non-clojure buffers?

borkdude 2020-11-12T11:53:38.445500Z

What are the best resources for someone already knowing some Clojure, but wanting to migrate from VSCode to emacs, to learn e.g. CIDER and emacs?

borkdude 2020-11-12T11:53:50.445800Z

Asking for @stevan.radanovic

pez 2020-11-12T12:15:30.449600Z

Basically one needs to know that M-x is the equivalent to the command palette. 😃 Also, I think the document that @plexus is putting together would be of help. Not sure how ready he is to share it this widely, though so I’ll let him decide that.

jmckitrick 2020-11-12T12:18:19.450Z

I've started a CIDER project using Starting server via /usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.2"} cider/cider-nrepl {:mvn/version "0.25.4"}}}' -A:dev -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'

jmckitrick 2020-11-12T12:18:41.450500Z

That's the output CIDER gives me. It does a bunch of work, but then never returns a working repl.

jmckitrick 2020-11-12T12:18:53.450800Z

I see both nrepl and cider-nrepl are injected.

plexus 2020-11-12T12:43:08.451700Z

happy to share, not sure how generally useful it is. It is deliberately splitting very fine hairs, which may not be very useful for a user looking for practical info https://docs.google.com/spreadsheets/d/1PjW5Vaz3-DSTx6fkfHVbwVV5J6cfKq3xttwnwgzNS8Q/edit#gid=919814025

plexus 2020-11-12T12:43:31.452100Z

It's more intended for people working on tools to be able to compare with prior art

borkdude 2020-11-12T12:43:59.452600Z

btw I have mapped my paredit keybindings such that they work the same in VSCode/Calva as in emacs/CIDER

practicalli-john 2020-11-12T13:06:19.453Z

I wont claim this is the best, but hopefully its useful. https://practicalli.github.io/spacemacs/

borkdude 2020-11-12T13:07:20.453200Z

^ @stevan.radanovic :)

❤️ 1
pez 2020-11-12T13:30:52.454600Z

@borkdude have you updated the emacs/CIDER bindings or the Calva ones?

borkdude 2020-11-12T13:31:03.454800Z

Calva ones

pez 2020-11-12T13:31:17.455100Z

Can I haz?

borkdude 2020-11-12T13:31:24.455300Z

lemme check

pez 2020-11-12T13:32:11.455800Z

If you post it as a gist I can link to it from the Calva docs.

borkdude 2020-11-12T13:32:34.456100Z

This is one: I'm not sure how to make a gist of this.

pez 2020-11-12T13:33:14.456800Z

There should be a keybindings.json file there on your machine somewhere…

jmckitrick 2020-11-12T13:41:53.457500Z

So here's where I'm confused... here is the command line I used to start the app:

jmckitrick 2020-11-12T13:42:11.457700Z

clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.2"} cider/cider-nrepl {:mvn/version "0.25.4"}}}' -M:dev -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'

jmckitrick 2020-11-12T13:42:46.458400Z

Which is right out of CIDER's jack-in setup, with an extra param -M:dev for clj tools config.

jmckitrick 2020-11-12T13:43:21.459200Z

You can see that nrepl (also in deps.edn already), cider-nrepl, and cider-middleware are all injected.

jmckitrick 2020-11-12T13:44:15.460200Z

However, when I run cider-connect-cljs and provide localhost and the port configured in the dev startup code for nrepl, I get a CIDER repl with this warning:

jmckitrick 2020-11-12T13:44:36.460400Z

'WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it!'

jmckitrick 2020-11-12T13:44:47.460700Z

So... what's missing or disconnected?

practicalli-john 2020-11-12T14:12:36.462700Z

@jmckitrick What configuration is in the :dev alias? Does it contain :replace-deps ?

jmckitrick 2020-11-12T14:13:15.463Z

no

dpsutton 2020-11-12T14:17:05.463400Z

Does it have its own main?

jmckitrick 2020-11-12T14:18:25.464200Z

Ok, I'm in business! Whew. So I had it working yesterday, then a rare git issue lost my changes (uncommitted, unstashed, etc...)

jmckitrick 2020-11-12T14:18:34.464500Z

But I'm trying a different approach now...

jmckitrick 2020-11-12T14:19:17.465500Z

I'm not sure it's ideal, and I'd rather handle this in deps.edn and CIDER rather than changing my company's startup code, even though it's only the dev endpoint.

jmckitrick 2020-11-12T14:30:48.466Z

Next is CLJS. It seemed like it was working, but:

jmckitrick 2020-11-12T14:30:50.466200Z

`[nREPL] Direct connection to localhost:9630 established [nREPL] Connection closed unexpectedly (connection broken by remote peer)`

jmckitrick 2020-11-12T14:31:03.466500Z

So it connects then immediately closes.

theeternalpulse 2020-11-12T15:00:25.468300Z

I tried creating a macro in a clojurescript project and adding a {:style/indent 1} meta tag and it indents fine if I use the macro in the same buffer but once I import it and use it in a cljs file it indents all arguments when I only want it to indent once. Is there something I'm missing to get the other buffer to pick up the indentation?

theeternalpulse 2020-11-12T16:08:10.469500Z

I noticed the change once I re-named the macro, if Ihave it start with "def" seems to indent normally without the style indent

dpsutton 2020-11-12T16:09:45.470700Z

i think the rules for indentation can be a bit simplistic but sometimes beneficial. Things that start with def (`defthingy`, etc) use the def rule. Same as functions/macros that start with with. Lots of times you get the intended behavior for free from the more simple matching rules but sometimes it is unintended

theeternalpulse 2020-11-12T16:10:20.471Z

right, but shouldn't setting the indentation spec take into effect?

theeternalpulse 2020-11-12T16:10:43.471700Z

(defmacro withstyles
  {:style/indent 1}
  [styles component]
  (let [bind-forms (style-bindings styles)]
    `(let [~@bind-forms]
       ~component)))

dpsutton 2020-11-12T16:10:51.472200Z

it sounds like there are two rules in conflict. i don't know how or even if there is a conflict resolution strategy

theeternalpulse 2020-11-12T16:10:56.472300Z

in the same buffer, the macro indents properly, but importing via require works

theeternalpulse 2020-11-12T16:11:14.472700Z

(withstyles [interact [grow pointer]
             grow [*interact another one]
             a [choice-a]
             b [choice-b]
             conditional [(if (= 1 1) a b)]]
  [:div {:class interact}
   [:div {:class grow}]
   [:div {:class conditional}]])

theeternalpulse 2020-11-12T16:11:24.473Z

that's in the clj file

theeternalpulse 2020-11-12T16:11:34.473300Z

(defn close-button []
  (withstyles [interact [dim pointer]
               position [absolute right-0]
               style [ma2 pa1 w1 h1 f5 ba br-100 b--transparent bg-red]]
              [:div {:class (classes interact position style)
                     :onClick #(unset-state! :dashboard/visible-topic)}]))

theeternalpulse 2020-11-12T16:11:58.473800Z

this is in a cljs file with the specification

(ns hot-topics.dashboard
  (:require-macros [hot-topics.tachyons :refer [withstyles]])
  ,,,)

dpsutton 2020-11-12T16:12:13.474100Z

do you have a cljs repl open and is the namespace loaded?

theeternalpulse 2020-11-12T16:12:20.474300Z

yeah

theeternalpulse 2020-11-12T16:12:33.474700Z

I even eval'd both buffers just in case

dpsutton 2020-11-12T16:12:41.475Z

then might be a bug with indentation in cljs. maybe open an issue with a minimal repro?

dpsutton 2020-11-12T16:13:15.475700Z

and is this the case only with def and with prefixes? ie if you rename this to foo does it behave correctly?

theeternalpulse 2020-11-12T16:15:20.476300Z

yeah, I just created a new one with a different name and same problem, interesting

dpsutton 2020-11-12T16:15:53.476600Z

maybe check the documentation if indentation metadata is supported at all for cljs?

theeternalpulse 2020-11-12T16:18:35.477Z

seems like (put-clojure-indent 'withstyles 1) does it

dpsutton 2020-11-12T16:19:08.477800Z

yeah that's the static stuff. i'm wondering if the metadata (and therefore nrepl support required) version works at all

bozhidar 2020-11-13T08:52:35.489100Z

I don't think anything from the track-state middleware works with ClojureScript.

bozhidar 2020-11-13T08:56:15.489300Z

My bad. It seems it should work. Haven't used cljs in a very long time, so my memory on the subject is fuzzy.

theeternalpulse 2020-11-12T16:19:47.478400Z

it seems to only work in the clj repl, maybe there's a communication issue with the metadata between clj/cljs

theeternalpulse 2020-11-12T16:20:17.479400Z

I'll try and make a minimal example when I have time and see if it's not already submitted, but you pointed me in the right direction

dpsutton 2020-11-12T16:20:22.479500Z

i would verify in documentation that this is supported at all before trying to diagnose a bug

dpsutton 2020-11-12T16:20:43.480Z

there are several features that are clj only when it comes to nrepl support. the debugger being an example that quickly comes to mind

theeternalpulse 2020-11-12T16:25:55.481900Z

true, I see I can't do (meta #'withstyles) in cljs, but in clj it's fine, so maybe that's just a limitation with cljs to find out how to indent forms

dpsutton 2020-11-12T16:27:53.482800Z

oh i filed a bug report that cljs drops some meta from defs like arglists. i wouldn't be surprised if this was similar. if you alter-meta that with-styles after explicitly you could check if that helps

theeternalpulse 2020-11-12T16:34:34.484100Z

no luck, I think as far as cljs is concerned it just knows the name and hands it off to the compiler to deal with

theeternalpulse 2020-11-12T16:34:57.484700Z

maybe I'll just have a localdirs with those declarations

theeternalpulse 2020-11-12T16:35:25.485300Z

I'm curious how it works with macros out in the wild as libs, how do they set it across the board for consumers

practicalli-john 2020-11-12T21:17:36.487100Z

Would a pull request be welcome for the issue I raised https://github.com/clojure-emacs/cider/issues/2922

dpsutton 2020-11-12T21:25:31.487700Z

@jr0cket comment left. suggested maybe just a new var that will be used as the whole connection argument if provided

practicalli-john 2020-11-13T12:21:09.489700Z

Does that mean I can just wrap an if statement around the call (cider--update-jack-in-cmd) at https://github.com/clojure-emacs/cider/blob/master/cider.el#L1006 Something like this?

(let ((params (thread-first params
                  (cider--update-project-dir)
                  (cider--check-existing-session)
                  (if cider-full-jack-in-command
                     :jack-in-cmd cider-full-jack-in-command
                    (cider--update-jack-in-cmd))))

practicalli-john 2020-11-13T12:41:18.490100Z

That code generates

error in process sentinel: Could not start nREPL server:
So I probably have the :jack-in-cmd cider-full-jack-in-command wrong...

practicalli-john 2020-11-13T12:52:57.490300Z

Or is it because I'm using an if in a thread-first macro?

practicalli-john 2020-11-13T13:05:03.491Z

Yes, something different about thread-first in elisp, as this code doesnt work either

(let ((params (thread-first params
                  (cider--update-project-dir)
                  (cider--check-existing-session)
                  (plist-put :jack-in-cmd cider-custom-jack-in-command))))
    (print cider-custom-jack-in-command)
    (print params)
    (nrepl-start-server-process
     (plist-get params :project-dir)
     (plist-get params :jack-in-cmd)
     (lambda (server-buffer)
       (cider-connect-sibling-clj params server-buffer))))
seems thread-first doesnt put params where I want it to be 😞

practicalli-john 2020-11-13T13:10:26.491200Z

Actually, looking through some of the other code, editing the cider-jack-in-clj function doesnt make sense, as a similar change would need to be made to the other cider-jack-in-* functions

practicalli-john 2020-11-13T13:13:32.491400Z

Looking at cider--update-jack-in-cmd is very confusing. So without further suggestions, I'm afraid I am stuck. Unless its okay to wrap an if after the let* and wrap the rest of the body of that function (that feels bad) I am not seeing the simplicity in this approach so far 🙂

practicalli-john 2020-11-13T13:27:19.491600Z

I've summarised this on the github issue https://github.com/clojure-emacs/cider/issues/2922#issuecomment-726763365

practicalli-john 2020-11-12T21:40:23.487900Z

Thanks for the feedback. Wouldn't replacing the whole command line require a lot more changes to the Cider code. I'll take another look and see if I understand that part of the code.

dpsutton 2020-11-12T21:45:31.488100Z

probably not. it ultimately ends up in a single string called cmd and a process is started like that

dpsutton 2020-11-12T21:48:12.488300Z

https://github.com/clojure-emacs/cider/blob/master/cider.el#L1279-L1285 is where the string is built up and here the string is just passed into nrepl-start-server-process https://github.com/clojure-emacs/cider/blob/master/cider.el#L1007-L1011

dpsutton 2020-11-12T21:48:38.488700Z

all you have to do is just not do any work when a string is given