Fork me on GitHub
#cider
<
2019-08-28
>
Yehonathan Sharvit13:08:46

Is there a way to quickly navigate to a var that is defined in the current namespace?

Yehonathan Sharvit13:08:00

I mean by typing partially the name of the var

stathissideris13:08:48

hello, I do cider-jack-in-clj&cljs. I have several questions: (1) I see logging output from the clj repl in the cljs repl. Is that expected? (2) If I close the cljs REPL only, and then do cider-jack-in-cljs figwheel-main tells me that the address (the port) is already being used. I thought I closed it already! (3) What does it mean for 2 REPLs to be “siblings”?

dpsutton13:08:27

@viebel check out imenu maybe?

Yehonathan Sharvit13:08:41

imenu looks awesome! Thanks @dpsutton. How does the integration with CIDER works?

dpsutton13:08:36

not at all. but you're still in emacs!

Yehonathan Sharvit13:08:58

emacs understand Clojure?

dpsutton13:08:19

imenu understands some top level forms yes

dpsutton13:08:33

just do m-x imenu in your buffer and see what you get

dpsutton13:08:37

its built in to emacs

Yehonathan Sharvit13:08:45

I saw and it looks great. I was just curious to understand how it works

dpsutton13:08:22

from clojure-mode: (add-to-list 'imenu-generic-expression '(nil clojure-match-next-def 0))

dpsutton13:08:48

(re-search-backward "^[ \t]*(\\([a-z0-9.-]+/\\)?\\(def\\sw*\\)" nil t) so its regex based

dpsutton13:08:02

looking for def* things

Yehonathan Sharvit13:08:02

I also saw once a CIDER buffer with the symbols of the current namespace but I don’t remember how to open this buffer

dpsutton13:08:43

cider-browse-ns ?

Yehonathan Sharvit13:08:06

Is there a quick way to browse the current namespace?

dpsutton13:08:45

(funcall-interactively 'cider-browse-ns (cider-current-ns))

Yehonathan Sharvit13:08:58

How can I add a keybinding for that?

(spacemacs/set-leader-keys-for-major-mode 'clojure-mode "hc" '(funcall-interactively 'cider-browse-ns (cider-current-ns)))
?

Yehonathan Sharvit13:08:24

I tried this ^ but It din’t work @dpsutton

dpsutton13:08:03

that needs to be a function. quoting turns it into a list of symbols

Yehonathan Sharvit14:08:24

I have still an issue. I am using helm-cider-mode

Yehonathan Sharvit14:08:07

When I run (cider-browse-ns (cider-current-ns))), it opens a buffer with the list of all the namespaces

Yehonathan Sharvit14:08:01

I think I found the issue in the code of helm-cider-mode:

defcustom helm-cider-overrides
  '((cider-apropos . helm-cider-apropos)
    (cider-apropos-select . helm-cider-apropos)
    (cider-apropos-documentation . helm-cider-apropos-symbol-doc)
    (cider-apropos-documentation-select . helm-cider-apropos-symbol-doc)
    (cider-browse-ns . helm-cider-apropos-ns)
    (cider-browse-ns-all . helm-cider-apropos-ns)
    (cider-browse-spec-all . helm-cider-spec))
  "Alist of CIDER functions and Helm versions replacing them."
  :group 'helm-cider
  :type '(alist :key-type symbol :value-type symbol))

mkvlr15:08:53

@viebel SPC j i in spacemacs helm-jump-in-buffer does what you want I think

Yehonathan Sharvit04:08:28

The command you mentioned opens imenu which is string based. I prefer (cider-browse-ns (cider-current-ns))

Quest16:08:07

Anyone have a recommended keybind for cider-eval-file (or cider-eval-buffer)?

bozhidar16:08:34

> (3) What does it mean for 2 REPLs to be “siblings”?

bozhidar16:08:03

@stathissideris It means they belong to the same CIDER session (usually different REPLs connected to the same server).

bozhidar16:08:24

> (2) If I close the cljs REPL only, and then do cider-jack-in-cljs figwheel-main tells me that the address (the port) is already being used. I thought I closed it already!

bozhidar16:08:40

I’m guessing that killing the nREPL connection doesn’t kill figwheel or something like this.

bozhidar16:08:56

> (1) I see logging output from the clj repl in the cljs repl. Is that expected?

bozhidar16:08:02

That definitely sounds like a bug to me.

stathissideris17:08:19

Thanks @bozhidar I’ll try and demonstrate (1) by setting up a minimal project

warnsberg18:08:34

I’m having some issues to get cider-connect-cljs to work with shadow-cljs – the REPL connects fine, but its type is clj which means the buffer integration from cljs buffers doesn’t work

warnsberg18:08:16

If I manually change the REPL type using cider-set-repl-type to cljs it’ll work, but the type reverts back to clj after each command I send

warnsberg18:08:32

I wonder if somethings wrong with my setup, does anyone recognize this behaviour?

warnsberg18:08:20

(also, cider-jack-in-cljs seems to work fine, so it seems to be related to cider-connect-cljs specifically)

dpsutton18:08:02

what version of shadow are you on?

dpsutton18:08:12

can you perhaps go back a version or two and see if that fixes it?

warnsberg18:08:50

Sure, any specific version?

dpsutton18:08:13

shot in the dark but 2.8.49?

dpsutton18:08:18

just a "few"

warnsberg18:08:42

Trying 2.8.46 – roughly two weeks old

warnsberg18:08:24

Getting some RuntimeException Unable to resolve var: cemerick.piggieback/*cljs-compiler-env* in this context errors for previous versions

warnsberg18:08:44

.46 and .49 both threw that error, trying .50 now

warnsberg18:08:28

Glancing over the changelogs a lot of versions around .47-.50 seems related to piggieback stuff

warnsberg19:08:19

Ok, 2.8.46 seems to be working as expected

warnsberg19:08:44

.47 works as well

warnsberg19:08:55

.48 seems to be broken, so https://github.com/thheller/shadow-cljs/commit/a4fc198a2296fdc53590b28d7afaefec03909e0e could have introduced the breakage, I suppose

dpsutton19:08:59

what versions of piggieback are going on?

warnsberg19:08:45

If I’ve understood things correctly, shadow-cljs doesn’t use piggieback at all, but mimics it under the hood

thheller19:08:37

true and I updated the emulation to remove the older stuff

thheller19:08:00

cemerick.piggieback is rather old and shouldn't be used anymore? are you on an old cider version? or nrepl?

warnsberg19:08:06

CIDER version is 0.22.0snapshot 20190826.11

warnsberg19:08:29

(probably the latest in spacemacs develop)

bozhidar19:08:28

And you don’t see anything related to tools.nrepl in your deps tree, right?

warnsberg19:08:01

Honestly not sure how I’d go about checking my deps tree, still pretty new to the entire clj(s) ecosystem

warnsberg19:08:28

I’m using deps.edn so I guess that could list all transative deps for me somehow

thheller19:08:42

don't forget to enable all the aliases and extra deps you might have though

warnsberg19:08:31

@bozhidar no tools.nrepl references

warnsberg19:08:00

❯ clj -Stree | grep nrepl
  nrepl/nrepl 0.6.0
refactor-nrepl/refactor-nrepl 2.4.0
cider/cider-nrepl 0.22.0-beta12

bozhidar19:08:13

Hmm, I’m assuming you must have something that’s depending on the old piggieback, otherwise I can’t imagine how you’d be getting such an error.

dpsutton19:08:20

what about clj -Stree | grep piggie

🐷 4
warnsberg19:08:12

Nope, but I got that error when I reverted the shadow-cljs version to older releases

thheller19:08:53

@warnsberg you should be on the latest shadow-cljs release (2.8.52) or something before all the nrepl mess

thheller19:08:59

not inbetween 😉

warnsberg19:08:00

But I think my real issue is as I described initially, with newer releases (> 2.8.48) CIDER seems to think that my cljs repl is a clj repl

warnsberg19:08:22

@dpsutton asked me to try older versions, so I did

dpsutton19:08:45

whoops 🙂

warnsberg19:08:45

But I’m seeing the issue with CIDER interpreting my REPL as a CLJ repl instead of a CLJS repl, so I cant send commands from my cljs buffers

thheller19:08:00

but the cider detection seems to be broken somehow. @manuel reported that yesterday too

warnsberg19:08:03

But things like (js/alert "foo") works just fine, so the REPL is indeed connected correctly

thheller19:08:28

so my changes must have broken it somehow. just not sure why yet.

warnsberg19:08:35

If I manually change the REPL type to cljs it will work for a single command, but then revert back to clj

dpsutton19:08:11

we should probably add an "ignore state tracker" option to CIDER for these annoying bits that come up. This shouldn't be a showstopper beyond the one time it falsely responds

dpsutton19:08:53

(defn- cljs-env-path
  "Returns the path in the session map for the ClojureScript compiler
  environment used by piggieback."
  []
  [(if nrepl-piggieback?
     (resolve 'piggieback.core/*cljs-compiler-env*)
     (resolve 'cider.piggieback/*cljs-compiler-env*))])
this could probably be smarter as well.

thheller19:08:23

cider.piggieback/*cljs-compiler-env* this should be bound. the other one doesn't exist

bozhidar19:08:53

Yeah, exactly.

dpsutton19:08:10

oh i was totally misreading this as cemerick vs cider rather than current vs future planned version

yenda19:08:56

@thheller not sure if this help but since I've had the issue as well I can add than if I manually change the repl-type to cljs, then call cljr-clean-ns, the repl-type switches back to clj, and this is the stack trace that changes it back:

Debugger entered--setting cider-repl-type in buffer *cider-repl ~/my-project:localhost:33673(cljs:shadow)* to clj: 
  debug--implement-debug-watch(cider-repl-type clj set #<buffer *cider-repl ~/my-project:localhost:33673(cljs:shadow)*>)
  cider-set-repl-type("clj")
  cider-repl--state-handler((dict "changed-namespaces" (dict) "id" "18" "repl-type" "clj" "session" "df02492d-a0c7-4553-b463-c45237d0c7c1" "status" ("state")))
  run-hook-with-args(cider-repl--state-handler (dict "changed-namespaces" (dict) "id" "18" "repl-type" "clj" "session" "df02492d-a0c7-4553-b463-c45237d0c7c1" "status" ("state")))
  nrepl-client-filter(#<process nrepl-connection> "d2:id2:182:ns17:app.camera.screen13:printed-valuei1e7:session36:df02492d-a0c7-4553-b463-c45237d0c7c15:value17:app.camera.screened2:id2:182:ns17:app.camera.screen13:printed-valuei1e7:session36:df02492d-a0c7-4553-b463-c45237d0c7c15:value17:app.camera.screened2:id2:187:session36:df02492d-a0c7-4553-b463-c45237d0c7c16:statusl4:doneeed18:changed-namespacesde2:id2:189:repl-type3:clj7:session36:df02492d-a0c7-4553-b463-c45237d0c7c16:statusl5:stateee")
all I understand is that the repl seems to advertise itself as being of repl-type" "clj" and cider keeps changing it back to that?

thheller19:08:54

yeah the track-state middleware is responsible for that. my changes seem to have messed with that.

yenda19:08:04

but additionally my colleagues on vanilla emacs don't have this issue

yenda19:08:10

and I use spacemacs

yenda19:08:21

ok I'm gonna try reverting

yenda19:08:07

because yeah they may be running with shadow 2.8.45

dpsutton19:08:00

can you try without refactor-nrepl? wild guess but maybe that's different?

yenda19:08:05

WARNING: No Clojure project was detected. The
refactor-nrepl middleware was not enabled. (You can mute this
warning by customizing `cljr-suppress-no-project-warning'.)
yeah I always have this prompt in the repl btw

yenda19:08:30

with 2.8.45, removing clj-refactor from deps I get a cljs repl with the right repl type

yenda19:08:46

still get the clj-refactor warning though

yenda19:08:22

2.8.52/no clj-refactor in shadow-cljs.edn (but still get warning about clj-refactor middleware in repl): wrong repl type

thheller20:08:14

just stick to the older version. don't have time to figure out what exactly broke right now.

yenda20:08:21

my guess would be that it is caused by the removal of piggieback middleware which does this https://github.com/nrepl/piggieback/blob/7bcda974b6df9aaae55d889c5f44507b47201cde/src/cider/piggieback.clj#L293-L310

yenda20:08:31

Ok seems to be confirmed by the fact that I can run 2.8.52 with [cider/piggieback "0.4.1"] and option :nrepl {:middleware [cider.piggieback/wrap-cljs-repl]} in shadow-cljs.edn

thheller20:08:16

shadow-cljs does not need or use piggieback at all. does this solve the CLJS REPL type detection issue?

yenda05:08:13

Yes shadow doesn't need it but apparently cider does because it sets some vars that are needed to determine the right repl type

yenda20:08:09

so one of these vars is required by nrepl to determine the right repl type

yenda20:08:36

So now I am back at my clj-refactor not working, with this warning in the repl:

WARNING: No Clojure project was detected. The
refactor-nrepl middleware was not enabled. (You can mute this
warning by customizing `cljr-suppress-no-project-warning'.)
and if I call clr-refactor-ns for instance I get Wrong type argument: stringp, nil

yenda20:08:06

also in the build:

shadow-cljs - config: /home/yenda/clash/shadow-cljs.edn  cli version: 2.8.52  node: v11.15.0
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by refactor_nrepl.inlined_deps.dynapath.v0v2v5.dynapath.defaults$eval8419$fn__8420 to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of refactor_nrepl.inlined_deps.dynapath.v0v2v5.dynapath.defaults$eval8419$fn__8420
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release