@jmckitrick Where do you get this?
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
@bozhidar ☝️:skin-tone-2:
Got it. I guess it's something coming from shadow, as it's certainly not coming from CIDER.
Probably cider-nrepl
is not on your classpath or something like this.
Yes, this is my first time trying to connect cider to a non-trivial tools.deps project with shadow.
Did you get my recent email? 🙂
@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.
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!
NP... anyway, I am 100% up and running and ready to help. No more excuses.
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?
I'm also decent at writing and proofreading docs.
@bozhidar I saw a 'todo' for switching between clj and cljs connections, IIRC. Would that be a good feature to tackle?
> 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 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.
@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?
It mentions we need to implement cycling as session can hold more than 2 REPLs
Sure.
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?
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?
do I want something like this in my .emacs file? (add-hook 'cider-mode-hook 'flycheck-mode)
I just enable it globally.
It defers to whatever linters are configured for the underlying major mode (or nothing).
interesting, what does that do in non-clojure buffers?
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?
Asking for @stevan.radanovic
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.
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"]'
That's the output CIDER gives me. It does a bunch of work, but then never returns a working repl.
I see both nrepl and cider-nrepl are injected.
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
It's more intended for people working on tools to be able to compare with prior art
btw I have mapped my paredit keybindings such that they work the same in VSCode/Calva as in emacs/CIDER
I wont claim this is the best, but hopefully its useful. https://practicalli.github.io/spacemacs/
^ @stevan.radanovic :)
@borkdude have you updated the emacs/CIDER bindings or the Calva ones?
Calva ones
Can I haz?
lemme check
If you post it as a gist I can link to it from the Calva docs.
This is one: I'm not sure how to make a gist of this.
There should be a keybindings.json
file there on your machine somewhere…
@pez https://gist.github.com/borkdude/6958364c88312713e62f13d8ba2b28e7
So here's where I'm confused... here is the command line I used to start the app:
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"]'
Which is right out of CIDER's jack-in setup, with an extra param -M:dev
for clj tools config.
You can see that nrepl (also in deps.edn already), cider-nrepl, and cider-middleware are all injected.
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:
'WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it!'
So... what's missing or disconnected?
@jmckitrick What configuration is in the :dev
alias? Does it contain :replace-deps
?
no
Does it have its own main?
Ok, I'm in business! Whew. So I had it working yesterday, then a rare git issue lost my changes (uncommitted, unstashed, etc...)
But I'm trying a different approach now...
https://docs.cider.mx/cider/0.26/basics/middleware_setup.html#using-embedded-nrepl-server
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.
Next is CLJS. It seemed like it was working, but:
`[nREPL] Direct connection to localhost:9630 established [nREPL] Connection closed unexpectedly (connection broken by remote peer)`
So it connects then immediately closes.
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?
I noticed the change once I re-named the macro, if Ihave it start with "def" seems to indent normally without the style indent
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
right, but shouldn't setting the indentation spec take into effect?
(defmacro withstyles
{:style/indent 1}
[styles component]
(let [bind-forms (style-bindings styles)]
`(let [~@bind-forms]
~component)))
it sounds like there are two rules in conflict. i don't know how or even if there is a conflict resolution strategy
in the same buffer, the macro indents properly, but importing via require works
(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}]])
that's in the clj file
(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)}]))
this is in a cljs file with the specification
(ns hot-topics.dashboard
(:require-macros [hot-topics.tachyons :refer [withstyles]])
,,,)
do you have a cljs repl open and is the namespace loaded?
yeah
I even eval'd both buffers just in case
then might be a bug with indentation in cljs. maybe open an issue with a minimal repro?
and is this the case only with def
and with
prefixes? ie if you rename this to foo
does it behave correctly?
yeah, I just created a new one with a different name and same problem, interesting
maybe check the documentation if indentation metadata is supported at all for cljs?
seems like (put-clojure-indent 'withstyles 1) does it
yeah that's the static stuff. i'm wondering if the metadata (and therefore nrepl support required) version works at all
I don't think anything from the track-state
middleware works with ClojureScript.
My bad. It seems it should work. Haven't used cljs in a very long time, so my memory on the subject is fuzzy.
it seems to only work in the clj repl, maybe there's a communication issue with the metadata between clj/cljs
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
i would verify in documentation that this is supported at all before trying to diagnose a bug
there are several features that are clj only when it comes to nrepl support. the debugger being an example that quickly comes to mind
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
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
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
maybe I'll just have a localdirs with those declarations
I'm curious how it works with macros out in the wild as libs, how do they set it across the board for consumers
Would a pull request be welcome for the issue I raised https://github.com/clojure-emacs/cider/issues/2922
@jr0cket comment left. suggested maybe just a new var that will be used as the whole connection argument if provided
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))))
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...Or is it because I'm using an if in a thread-first macro?
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 😞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
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 🙂
I've summarised this on the github issue https://github.com/clojure-emacs/cider/issues/2922#issuecomment-726763365
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.
probably not. it ultimately ends up in a single string called cmd
and a process is started like that
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
all you have to do is just not do any work when a string is given