Fork me on GitHub
#cider
<
2020-03-23
>
vinnyataide07:03:39

hello, I'm trying to use refactor on my jacked-in project with shadow-cljs but it keeps saying

user-error: The refactor-nrepl middleware isn't available! Did you remember to install it?

vinnyataide07:03:12

maybe I'm inside a cljs repl which doesn't have it in it's classpath?

vinnyataide07:03:37

my commands are jack in (shadow/watch :main) then (shadow/repl :main)

Michaël Salihi08:03:31

you can add the line :nrepl {:middleware [refactor-nrepl.middleware/wrap-refactor]} in shadow-cljs.edn config file. More info about: https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL

👍 4
Michaël Salihi08:03:31

you can add the line :nrepl {:middleware [refactor-nrepl.middleware/wrap-refactor]} in shadow-cljs.edn config file. More info about: https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL

👍 4
bozhidar08:03:23

@vinnyataide I guess you can also remove clj-refactor.el if you don’t need it.

bozhidar08:03:48

Are you using some Emacs distro that bundles it or something like this?

bozhidar08:03:10

So, you’ve installed clj-refactor yourself but it’s injecting its own deps?

vinnyataide09:03:37

I've just removed it I don't know why it was installed

zilti15:03:49

What can I do about error in process filter: Sync nREPL request timed out (op eval code (require 'shadow.cljs.devtools.api) enlighten true) ?

zilti16:03:32

It also opens two REPL buffers, with exactly the same names, on the same port. One with ClojureScript REPL init form, one without. Both claim to be ClojureScript REPLs.

dpsutton16:03:24

what kind of project and how are you starting it?

zilti16:03:15

@dpsutton A deps.edn project, and I am starting it with cider-jack-in-clj&cljs

zilti16:03:11

cider-jack-in-cljs blows up, too, with the same error

dpsutton16:03:21

can you run the commands from a command line?

dpsutton16:03:33

get better feedback

dpsutton16:03:33

how do you start your cljs project? is it a shadow project?

dpsutton16:03:43

ah, you can't do clj&cljs then. surprised that cljs only is breaking

zilti16:03:45

Yes, it is a shadow project

zilti16:03:13

cljs uses /usr/bin/clojure -A:dev -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/piggieback {:mvn/version "0.4.2"} cider/cider-nrepl {:mvn/version "0.24.0-SNAPSHOT"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'

zilti16:03:30

"ClojureScript REPL type: shadow-select"

dadair16:03:02

Is it possible for cider-browse-spec to follow aliased specs? e.g., with ::some-alias/foo at point, show the spec for :the.fully.qualified.spec/foo?

yuhan06:03:42

I have a hack around this on my local branch of Cider, by macroexpanding namespace-aliased symbols in cider-symbol-at-point:

(defun cider-symbol-at-point (&optional look-back)
  "Return the name of the symbol at point, otherwise nil.
Ignores the REPL prompt.  If LOOK-BACK is non-nil, move backwards trying to
find a symbol if there isn't one at point."
  (or (when-let* ((str (thing-at-point 'symbol)))
        ;; resolve ns-aliased keywords
        (when (string-match-p "^::.+" str)
          (setq str (or (ignore-errors (cider-sync-request:macroexpand "macroexpand-1" str)) "")))
        (unless (text-property-any 0 (length str) 'field 'cider-repl-prompt str)
          ;; Remove font-locking and trailing . from constructors like Record.
          (string-remove-suffix "." (substring-no-properties str))))
      (when look-back
        (save-excursion
          (ignore-errors
            (when (looking-at "(")
              (forward-char 1))
            (while (not (looking-at "\\sw\\|\\s_\\|\\`"))
              (forward-sexp -1)))
          (cider-symbol-at-point)))))

👍 4
yuhan06:03:25

Not sure if that's the best way of doing it

jumar07:03:48

I often find helpful to jump to the definition of the keyword via cider-find-keyword

yuhan10:03:48

Huh, that's the first time I came across that command.. and it makes so many faulty assumptions

yuhan10:03:10

(ns foo
  (:require [clojure.spec.alpha :as s]))

(s/def :thing/id string?)
eg. something like this doesn't work

dpsutton16:03:07

you need to use shadow-cljs to start not clojure

dpsutton16:03:24

have you set the preferred build tool? you should be asked which build tool to use

zilti16:03:33

I have set that, yes

dpsutton16:03:33

that's your problem. you need to use the shadow-cljs build tool, not clojure

zilti16:03:56

So what do I do then? It is a mixed project that uses both Clojure and ClojureScript.

dpsutton16:03:18

start the clojure project with clj and the cljs project with shadow

dpsutton16:03:21

use both build tools

zilti16:03:35

And why does the prompt offer me "shadow" and "shadow-select" when starting a REPL with deps.edn when that is not working anyway

dpsutton16:03:53

those are clojurescript repl types not build tool types

zilti16:03:56

Well, it seems to not be possible to set a separate "preferred build tool" for CLJ and CLJS

bozhidar08:03:50

I’ve decided a long time ago that this a bit excessive as most build tools are not specific to Clojure/ClojureScript, that’s why there’s just one build tool config. I think that shadow-cljs is probably the only one that defies this. It’s easy to configure the build tool on a project basis, which I think covers the use-case of most people pretty well.

zilti17:03:28

Oh and it looks like shadow-cljs can also handle the clj repl, not just the cljs one. So I can just set the preferred build tool to shadow-cljs. Though I currently fail to do that in .dir-locals.el...

((nil . ((cider-preferred-build-tool . 'shadow-cljs))))
at least gives me an error.

dpsutton16:03:09

correct. there's no notion like that

yuhan06:03:42

I have a hack around this on my local branch of Cider, by macroexpanding namespace-aliased symbols in cider-symbol-at-point:

(defun cider-symbol-at-point (&optional look-back)
  "Return the name of the symbol at point, otherwise nil.
Ignores the REPL prompt.  If LOOK-BACK is non-nil, move backwards trying to
find a symbol if there isn't one at point."
  (or (when-let* ((str (thing-at-point 'symbol)))
        ;; resolve ns-aliased keywords
        (when (string-match-p "^::.+" str)
          (setq str (or (ignore-errors (cider-sync-request:macroexpand "macroexpand-1" str)) "")))
        (unless (text-property-any 0 (length str) 'field 'cider-repl-prompt str)
          ;; Remove font-locking and trailing . from constructors like Record.
          (string-remove-suffix "." (substring-no-properties str))))
      (when look-back
        (save-excursion
          (ignore-errors
            (when (looking-at "(")
              (forward-char 1))
            (while (not (looking-at "\\sw\\|\\s_\\|\\`"))
              (forward-sexp -1)))
          (cider-symbol-at-point)))))

👍 4