Fork me on GitHub
#cider
<
2019-10-30
>
fiddlerwoaroof01:10:58

Has anyone successfully setup jump to definition from clojure to Java?

dominicm08:10:21

Yes. Not with decompilation though.

dominicm08:10:36

You just need sources on the classpath

futuro23:10:10

The hard part I’ve run into is automatically downloading sources, and adding them to the classpath

dominicm05:10:57

There's a lein plugin kicking around

futuro11:10:36

Do you remember it’s name? I’d love to have this in plugin form.

dominicm11:10:06

It was on an issue on github for either cider / cider-nrepl.

dominicm11:10:15

the plugin was hosted on gitlab

dominicm11:10:06

worked out of the box with vim, so should also work for emacs

dominicm11:10:10

You commented on that issue, so maybe it didn't work for you 🙂 but maybe you missed, dunno

fiddlerwoaroof21:10:23

Thanks, I'll look into that

fiddlerwoaroof21:10:30

Has anyone worked on decompilers?

fiddlerwoaroof21:10:02

And synchronizing the classpath with something like lsp-java?

fiddlerwoaroof01:10:21

(and, possibly, decompilation of class files if the source isn't available)

dpsutton02:10:30

@macrobartfast how are you starting your cljs project?

macrobartfast02:10:45

I start it with

lein repl

macrobartfast02:10:56

then switch to emacs, and then

macrobartfast02:10:35

followed by, in the repl that appears in emacs

macrobartfast02:10:45

(use 'figwheel-sidecar.repl-api)

macrobartfast02:10:16

(start-figwheel!)

macrobartfast02:10:28

at that point, the site appears, and reflects changes to the code, but, cider-eval-defun-at-point for any :require produces a class not found exception or the equivalent.

macrobartfast02:10:26

causes

Unable to resolve symbol: + in this context

dpsutton02:10:34

ok. you still have a clojure repl. you need to start a clojurescript repl. can you try cider-jack-in-clojurescript and select figwheel as your repl type?

dpsutton02:10:54

but to do this you'll need to have figwheel sidecar in your deps

dpsutton02:10:12

do you have cider-nrepl in your deps so lein repl includes it?

dpsutton02:10:27

i'm wondering if there's any CIDER stuff at all

macrobartfast02:10:05

hmm... I've found all the figwheel stuff commented out...

macrobartfast02:10:45

the project was the result of

lein new app test -- --reagent"

macrobartfast02:10:21

I could have also done

lein new reagent test
which is something I'm not clear on.

macrobartfast02:10:43

so I'll uncomment the figwheel stuff and see what happens.

dpsutton02:10:17

have you read the figwheel docs to see what is required?

macrobartfast02:10:20

I tried to read them... it has become very confusing as there seem to be quite a few variations on how to go about it.

macrobartfast02:10:35

and shadow-cljs has only made it more complex for me.

macrobartfast02:10:33

right now though, I'm regenerating a project with

lein new reagent test
as opposed to
lein new app test -- --reagent
and will see if the problem persists.

macrobartfast02:10:44

well, generating a project with

lein new reagent testtwo
then starting a repl with
lein repl
and connecting to it from emacs via
cider-connect
and then, in the emacs repl,
(use 'figwheel-sidecar.repl-api)
followed by
(start-figwheel!)
allows me to evaluate
(+ 1 1)
from a cljs buffer, but any eval of a namespace declaration with a :require such as
(ns testtwo.core
  (:require
   [reagent.core :as reagent :refer [atom]]
   [reagent.session :as session]
   [reitit.frontend :as reitit]
   [clerk.core :as clerk]
   [accountant.core :as accountant]))
in this case produces an
Unhandled java.lang.IllegalAccessError
   atom does not exist
error and commenting that out causes the same error to be thrown on the reagent.session :require and so on right down the line.

macrobartfast03:10:32

I'm guessing this has something to do with my needing a cljs repl instead of a clj one, or something, as my buffer is a cljs one, but dunno.

dpsutton03:10:51

yeah. you're just starting a clojure repl. lein-figwheel is a bit old. are you sure you can't try out shadow?

macrobartfast03:10:02

I can and should.

dpsutton03:10:13

cool. i think you'll have a better time with that

dpsutton03:10:32

and if you configure it in a standard way you can just run cider-jack-in-cljs and it will all work

macrobartfast03:10:46

ok. I'm super afraid of the shadow-cljs learning curve.

aisamu14:10:56

You really shouldn't be! It's as straightforward as the alternatives, and brings some very nice things to the table if you rely on npm libs.

macrobartfast03:10:02

and I'll try cider-jack-in-cljs now.

dpsutton03:10:35

It’s far smaller than lein figwheel

dpsutton03:10:07

And suggestion. Get it running where you have a repl from the command line and only then try putting CIDER in

macrobartfast04:10:51

just a sanity check, first... I assume I'll be able to evaluate forms from within a buffer in emacs as per usual when I use shadow-cljs in my pipeline, right?

macrobartfast04:10:58

I guess that is the role of cider, which seems to still play well with shadow-cljs.

dpsutton05:10:24

yes. get your project working from the command line first though

dpsutton05:10:37

but you'll be able to evaluate in line in the buffer, have a repl in emacs, all the goodies

bartuka09:10:14

is it possible to change the indentation of vectors to match the following requirements:

clojure
(defrecord Valores [])

[Valores (= 1 1)
 (= 2 2)
 (= 2 3)]

[Valores (= 1 1)
         (= 2 2)
         (= 2 3)]

jumar09:10:22

As mentoined here https://clojurians.slack.com/archives/CEFN9UP8R/p1572424846034600, I'm trying to setup rebl with cider. I managed to make it work with plain lein repl but not with a complete cider setup. It fails when starting the repl:

[nREPL] Starting server via /usr/local/bin/lein update-in :dependencies conj \[nrepl\ \"0.6.0\"\] -- update-in :plugins conj \[refactor-nrepl\ \"2.5.0-SNAPSHOT\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.22.3\"\] -- repl :headless :host localhost


Error loading nrebl.middleware: Syntax error compiling at (nrebl/middleware.clj:1:1).
...
Syntax error compiling var at (/private/var/folders/hn/tgwyrdmj1tb5pmmbdkd1g_qc0000gn/T/form-init8412568572949758697.clj:1:10031).
Unable to resolve var: nrebl.middleware/wrap-nrebl in this context

When I manually edit the start command to just lein repl then it works (but obviously cider repl is sort of broken)

jumar09:10:32

Is this a known limitation or is there a way how to make REBL work with cider?

bozhidar11:10:33

I thought nrebl was the way, but I’ve never tested it.

bozhidar11:10:25

I’m guessing you also have to add this to your list of plugins/middleware for it to be loaded properly (unless it’s set up in your project.clj).

jumar11:10:28

I added it to my ~/.lein/profiles.clj as mentioned in the linked thread. Here's the current version (minus lot of other stuff):

{
 :user
 {

  :dependencies [

                 ;; REBL
                 ;; 
                 [rickmoynihan/nrebl.middleware "0.3.1"] ;; set this to the latest nrebl version
                 [org.clojure/core.async "0.4.500"]
                 ;; to support java 11: 
                 ;;    or rather 
                 [org.openjfx/javafx-fxml "11.0.1"]
                 [org.openjfx/javafx-controls "11.0.1"]
                 [org.openjfx/javafx-graphics "11.0.1"]
                 [org.openjfx/javafx-media "11.0.1"]
                 [org.openjfx/javafx-swing "11.0.1"]
                 [org.openjfx/javafx-base "11.0.1"]
                 [org.openjfx/javafx-web "11.0.1"]
                 ;; downloaded to "/Users/jumar/tools/clojure/rebl/REBL-0.9.220/REBL-0.9.220.jar"
                 ;; and installed to the local maven repo:
                 ;;   mvn install:install-file -Dfile=REBL-0.9.220.jar -DgroupId=com.cognitect -DartifactId=rebl -Dversion=0.9.220 -Dpackaging=jar
                 [com.cognitect/rebl "0.9.220"]
                 ]


  ;; REBL - must be inlined in :user, cannot be separated to :nrebl profile
  ;; see 
  ;; TODO: make this work!!!
  :repl-options {:nrepl-middleware [nrebl.middleware/wrap-nrebl]}


  :injections [
               ;; REBL
               (require '[cognitect.rebl :as rebl])
               ]

  }}

jumar11:10:37

I'm gonna try if it works with just this minimalistic version

jumar11:10:28

Nope, the same error again:

Syntax error compiling var at (/private/var/folders/hn/tgwyrdmj1tb5pmmbdkd1g_qc0000gn/T/form-init10118661615782107768.clj:1:9797).
Unable to resolve var: nrebl.middleware/wrap-nrebl in this context

jumar11:10:41

@U06HHF230 I'm not sure if you're using Cider or not but perhaps you have some advice on this?

rickmoynihan23:10:38

Hi @U06BE1L6T. Yes, when I use nrebl I use it with cider. I’ve not used it with leiningen for a while, and tbh I don’t tend to use REBL much on a day to day basis. Regarding the nrebl profile I tend to have nrebl and other profiles defined, and then merge them into :user e.g.

:nrebl {:repl-options {:nrepl-middleware [nrebl.middleware/wrap-nrebl]}
         :dependencies [[rickmoynihan/nrebl.middleware "0.2.1-SNAPSHOT"]
                        ;;[rickmoynihan/nrebl.middleware "0.2.0"]
                        [org.clojure/core.async "0.4.490"]

                        [org.openjfx/javafx-fxml "11.0.1"]
                        [org.openjfx/javafx-controls "11.0.1"]
                        [org.openjfx/javafx-swing "11.0.1"]
                        [org.openjfx/javafx-base "11.0.1"]
                        [org.openjfx/javafx-web "11.0.1"]



                        ]
         :resource-paths ["/Users/rick/Software/rebl/REBL-0.9.220.jar"]
         :injections [(require '[cognitect.rebl :as rebl])]
         }

 :user [
        :nrebl
        :cider
,,,
        ]

rickmoynihan23:10:33

how are you starting it, cider-jack-in? I tend to cider-connect to a lein repl run from a terminal

jumar07:10:59

@U06HHF230 I've tried the "profile merging" option but it didn't work at all (I have many other things in profiles.clj) But as posted above I've also tried a minimalistic profiles.clj with the same result. I don't normally use cider-connect, always cider-jack-in which runs something like this:

/usr/local/bin/lein update-in :dependencies conj \[nrepl\ \"0.6.0\"\] -- update-in :plugins conj \[refactor-nrepl\ \"2.5.0-SNAPSHOT\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.22.3\"\] -- repl :headless :host localhost

jumar07:10:05

With plain lein repl and cider-connect I get this warning:

WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it!
         More information.WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0-SNAPSHOT (package: 20190618.716) and n/a, respectively.

jumar07:10:42

I tried to profile merging again with cider-nrepl, but still the same error, now even with plain lein-prel

Error loading nrebl.middleware: Syntax error compiling at (nrebl/middleware.clj:1:1).
Syntax error compiling var at (/private/var/folders/hn/tgwyrdmj1tb5pmmbdkd1g_qc0000gn/T/form-init7074044914497216362.clj:1:9555).
Unable to resolve var: nrebl.middleware/wrap-nrebl in this context

jumar07:10:09

Perhaps this error message can be relevant - I'm getting that for all lein commands:

lein -v
Error: cannot resolve lein-tools-deps.plugin/resolve-dependencies-with-deps-edn middleware
Leiningen 2.9.1 on Java 11.0.2 OpenJDK 64-Bit Server VM

jumar07:10:39

I have no idea where that's coming from though (maybe I just forgot). Is it somehow bundled in the leinigen itself?

jumar08:10:36

I tried to for the nrebl.middleware repo and ran lein repl there -> it fails with the similar error. When I remove this line it sort of works: https://github.com/RickMoynihan/nrebl.middleware/blob/master/project.clj#L29 However, I cannot require the namespace:

lein do clean, repl
nREPL server started on port 49538 on host 127.0.0.1 - 
REPL-y 0.4.3, nREPL 0.6.0
Clojure 1.10.1
OpenJDK 64-Bit Server VM 11.0.2+9
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (require '[nrebl.middleware])
Syntax error (FileNotFoundException) compiling at (nrebl/middleware.clj:1:1).
Could not locate cognitect/rebl__init.class, cognitect/rebl.clj or cognitect/rebl.cljc on classpath.

jumar08:10:28

But I have no idea how this thing is supposed to work so I don't know if it really make sense to use it like this

rickmoynihan09:10:41

are you also sure you’re running it on clojure 1.10.1?

rickmoynihan09:10:51

I can confirm I can recreate the issue. Not sure what it is either. rebl is a bit of a PITA tbh I think largely because it’s shipped as a binary, and it has some weird dependency issues that it weirdly pushes downstream. Not sure if that might be what is causing it — if you can downgrade REBL you might have more luck. Another complication might be the Java version. Are you running it on java 11 or java 8? If not why are you including the java 11 FX deps? Some bits of cider/leiningen might not work properly on that, not sure.

jumar10:10:57

I'm using Java 11 and clojure 1.10.1

jumar10:10:28

Leiningen 2.9.1 on Java 11.0.2 OpenJDK 64-Bit Server VM
Clojure 1.10.1

jumar13:10:12

Hmm, I can confirm it works with 0.9.157. Unfortunately, I don't have access to newer versions before 0.9.220. I guess they are not publicly available, right?

rickmoynihan13:10:37

I’d ask in #rebl but yeah as far as I’ve seen cognitect currently only supply the latest version.

jumar13:10:08

Well it sort of works. I got this exception when trying tap> (which might be a known issue in the old version):

Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: com/sun/javafx/jmx/MXNodeAlgorithm
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lan

rickmoynihan13:10:59

the tap panel in rebl only started working recently afaik

👍 4
jumar13:10:32

Anyway, thanks a ton for your help. I'll see if I can get a working solution anytime soon..

rickmoynihan13:10:39

n/p let me know how you get on; and maybe file an issue describing any findings. I find REBL pretty hard to test and work against because of its binary nature and there are various incompatibilities and dependency issues that can arise which are hard to debug because it’s so inscrutable.

practicalli-johnny13:10:49

@macrobartfast I have been using lein new figwheel-main project-name -- --reagent for my projects. Works very well with clojurescript-jack-in. I havent found the opportunity to try out shadow-clj and figure out what npm packages I want to use. There is a reasonably simple example of a figwheel-main project here https://github.com/practicalli/practicalli-landing-page

practicalli-johnny13:10:21

There is also an article if you decide to use Clojure CLI tools and deps.edn instead of Leiningen https://practicalli.github.io/blog/posts/development-workflow-with-clojure-cli-tools/

aisamu14:10:56

You really shouldn't be! It's as straightforward as the alternatives, and brings some very nice things to the table if you rely on npm libs.

macrobartfast17:10:35

thank you all! ( @dpsutton @jr0cket @aisamu ) I feel much better about all this thanks to your help. 😉

cider 8
futuro23:10:21

@iagwanderson clojure-mode defines indentation, though I can’t remember the setting off the top of my head

bartuka23:10:26

thanks @U0JJ68RBR I will try to take a look at this later

👍 4