Fork me on GitHub
#cider
<
2020-11-12
>
bozhidar07:11:54

@jmckitrick Where do you get this?

jmckitrick10:11:05

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

jmckitrick10:11:17

@U051BLM8F ☝️:skin-tone-2:

bozhidar10:11:59

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

bozhidar10:11:18

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

jmckitrick10:11:10

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

jmckitrick10:11:23

Did you get my recent email? 🙂

jmckitrick12:11:56

@U051BLM8F 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.

bozhidar11:11:38

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!

jmckitrick11:11:19

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

jmckitrick11:11:23

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?

jmckitrick11:11:40

I'm also decent at writing and proofreading docs.

jmckitrick17:11:09

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

bozhidar07:11:32

> 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.

bozhidar07:11:17

> @U051BLM8F 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.

jmckitrick13:11:56

@U051BLM8F 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?

jmckitrick13:11:11

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

jmckitrick20:11:39

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 Newton09:11:54

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 Newton09:11:54

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

bozhidar10:11:50

I just enable it globally.

Jim Newton11:11:00

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

bozhidar11:11:59

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

borkdude11:11:38

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?

practicalli13:11:19

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

borkdude13:11:20

^ @stevan.radanovic :)

❤️ 1
borkdude11:11:50

Asking for @stevan.radanovic

pez12:11:30

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.

jmckitrick12:11:19

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"]'

jmckitrick12:11:41

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

jmckitrick12:11:53

I see both nrepl and cider-nrepl are injected.

plexus12:11:08

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

plexus12:11:31

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

borkdude12:11:59

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

pez13:11:52

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

pez13:11:17

Can I haz?

borkdude13:11:24

lemme check

pez13:11:11

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

borkdude13:11:34

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

pez13:11:14

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

jmckitrick13:11:53

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

jmckitrick13:11:11

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"]'

jmckitrick13:11:46

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

jmckitrick13:11:21

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

jmckitrick13:11:15

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:

jmckitrick13:11:36

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

jmckitrick13:11:47

So... what's missing or disconnected?

practicalli14:11:36

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

dpsutton14:11:05

Does it have its own main?

jmckitrick14:11:25

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

jmckitrick14:11:34

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

jmckitrick14:11:17

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.

jmckitrick14:11:48

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

jmckitrick14:11:50

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

jmckitrick14:11:03

So it connects then immediately closes.

theeternalpulse15:11:25

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?

theeternalpulse16:11:10

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

dpsutton16:11:45

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

theeternalpulse16:11:20

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

theeternalpulse16:11:43

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

dpsutton16:11:51

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

theeternalpulse16:11:56

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

theeternalpulse16:11:14

(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}]])

theeternalpulse16:11:24

that's in the clj file

theeternalpulse16:11:34

(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)}]))

theeternalpulse16:11:58

this is in a cljs file with the specification

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

dpsutton16:11:13

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

theeternalpulse16:11:33

I even eval'd both buffers just in case

dpsutton16:11:41

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

dpsutton16:11:15

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

theeternalpulse16:11:20

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

dpsutton16:11:53

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

theeternalpulse16:11:35

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

dpsutton16:11:08

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

bozhidar08:11:35

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

bozhidar08:11:15

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

theeternalpulse16:11:47

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

theeternalpulse16:11:17

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

dpsutton16:11:22

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

dpsutton16:11:43

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

theeternalpulse16:11:55

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

dpsutton16:11:53

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

theeternalpulse16:11:34

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

theeternalpulse16:11:57

maybe I'll just have a localdirs with those declarations

theeternalpulse16:11:25

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

practicalli21:11:36

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

dpsutton21:11:31

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

dpsutton21:11:31

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

practicalli21:11:23

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.

dpsutton21:11:31

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

dpsutton21:11:38

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

practicalli12:11:09

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))))

practicalli12:11:18

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...

practicalli12:11:57

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

practicalli13:11:03

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 😞

practicalli13:11:26

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

practicalli13:11:32

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 🙂