Fork me on GitHub
#cider
<
2023-10-06
>
vemv18:10:27

Loading parentheses... oparen loading cparen

vemv18:10:52

CIDER master / snapshot introduces Java doc comment rendering and improved type inference for Java interop. You need to enable enrich-classpath as described https://docs.cider.mx/cider/config/basic_config.html#use-enrich-classpath. What does that mean? • Java doc comments (informally "docstrings", "javadocs") are rendered from their not-exactly-html format into a readable, syntax-colored format that is guaranteed to reasonably fit into UI widgets, without resorting to dumb trimming • Arglists are rendered with useful type info expressed as metadata: ^PrintStream [this, ^java.util.Locale l, ^String format, ^Object args] • Provided that you use type hints (as you already might be doing, to zap reflection warnings), and sometimes without hints at all, we can provide very accurate Java interop completion and documentation . This functionality can be seen in: • https://docs.cider.mx/cider/usage/code_completion.html#auto-completionM-x cider-dochttps://docs.cider.mx/cider/config/eldoc.htmlhttps://docs.cider.mx/cider/usage/working_with_documentation.html#displaying-documentation-as-tooltips 30 second demo:

🎉 14
💯 2
2
👏 2
aisamu19:10:06

This is great! Thank you!

🍻 1
Zachary20:10:20

Neat! One issue I’m having when enabling this is that my java-source alias no longer goes to definition when I M-. xref-find-definitions. Emacs hangs indefinitely(?) until I C-g. Definitely excited to see more support for java lookup! One thing I haven’t gotten to work yet is to do lookup on included java libraries or clojure’s java implementation. (I manually go to file if I care enough to understand more.)

:src/java20
  {:extra-deps
   {openjdk/java-sources {:local/root "<my-local-java-src>"}}}

vemv20:10:18

Thanks for the input! I don't recommend that style of aliases. Adding java sources 'manually' can be problematic, for contrived reasons. By using enrich-classpath, the same sources (and then some more: Clojure's, those of 3rd-party deps, and so on) are added, but in a way that isn't problematic (technically: they're placed at the end of the classpath). enrich-classpath recently got tools.deps support and I've duly fixed all little issue reports - often in less than 2 hours from report to release time. I'd suggest giving it a try, and if it fails feel free to report a GH issue right away.

vemv09:10:43

I tried xref-find-definitions specifically and it works. If it keeps being a problem (especially if you enable Enrich and disable the custom alias), please perform (setq nrepl-log-messages t), retry, and create a GH issue attaching the *nrepl-messages* buffer. Thanks!

Zachary23:10:11

Yes, xref-find-definitions is working for me as well, but wasn’t when I had set the java-sources manually. I’m excited that this is working now “out of the box”. 👏 A few things: • I’m noticing that xref-find-definition works only if connected to REPL. It hangs otherwise. I’m usually connected, and I think this was similar to before, so not a big deal. • When jacking in, a java process begins to download hundreds of megabytes from maven and clojars, thus taking quite a while to connect to repl. This happens even on subsequent jack-ins. This is only happening when cider-enrich-classpath is set. Connects immediately otherwise. 👀 ⏲️ • When I xref-find-definition on Clojure java source, or other imported Java library, No definitions are found (I have never been able to get this to work, wonder if it’s in-scope for enrich-classpath/intended to work/how to make work? 🤷

vemv07:10:19

For the first bullet point, it's normal that it doesn't work, but it's not that it hangs 😱 I'll file an issue. For the second, it would surprise me very much. Caching is one of enrich-classpath's more stable parts, it's described https://github.com/clojure-emacs/enrich-classpath#notes-on-caching. Are you sure you are trying the same project, with the same profiles? If it persists, after a successful jack in please check that the following files exist: /.cache/enrich-classpath-cache (file), /.cache/mx.cider/ (dir) For the last point, it's one of most basic things that Enrich does. Feel free to file an issue, attaching your classpath (please grab it with ps aux | grep java - one of the entries should correspond to your project). Example: https://gist.githubusercontent.com/vemv/d307061feb0d67d602bf93947730cb91/raw/20bf234b1adac7b8cdb8a69e4fa2f9b13daf9f64/gistfile1.txt ...if the classpath doesn't include something like mx.cider/enrich-classpath/<some digits>.jar, that's the problem

vemv07:10:00

I tried to repro the first bug, but couldn't. What's your value for xref-backend-functions when in clojure mode and not connected? For me it's (etags--xref-backend)

vemv08:10:26

...I sense that if you used M-x cider-find-var instead (at least as a temp experiment) you'd get the correct results, and no blocking. Probably something else is shadowing the cider xref backend.

Zachary00:10:24

As for the downloading upon successive jack-ins… It doesn’t seem to be doing that anymore. I think I may have been switching between different java versions at that time, causing this. That said, jacking-in with enriched class-paths takes 16 seconds, whereas it takes 2 seconds otherwise. With enriched enabled, I do notice a bash process calling instead, and also Java Class: clojure main process making network calls, but not significantly (anymore)…

Zachary00:10:05

When I ps aux | grep java there is indeed no …enrich-classpath…. How to ensure this is there? The /.cache/enrich… and /.cache/mx.cider files are present so that’s all good.

Zachary00:10:32

My xref-backend-functions returns (cider--xref-backend t), so that’s different and may explain the difference there. Definitely hanging still for me when not connected, but does that also with enrich-classpath not set, so probably not enrich-classpath.

vemv04:10:05

but not significantly (anymore)…that's the caching in action, so that's good news 👍 > The /.cache/enrich… and /.cache/mx.cider files are present so that’s all good. So, the files exist in disk but they're not in the final classpath, it seems? One likely explanation is that the jack in with the bash process (i.e. with enrich-classpath) failed, so the .sh script decided to fall back to not use enrich-classpath When that happens, normally the cause is printed to *messages*, do you see anything?

vemv04:10:07

> My xref-backend-functions returns (cider--xref-backend t), so that’s different and may explain the difference there. Sounds like some piece of config is adding it for you eagerly. You should only see that value after jacking in / connecting

Zachary04:10:24

Not seeing anything in *messages* :,/

vemv04:10:00

Say that you see:

[nREPL] Starting server via bash /Users/vemv/.emacs.d/lib/cider/clojure.sh /usr/local/bin/clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.0.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.39.1\"\}\ refactor-nrepl/refactor-nrepl\ \{\:mvn/version\ \"3.9.0\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[refactor-nrepl.middleware/wrap-refactor\,cider.nrepl/cider-middleware\]\"\]\}\}\} -M:dev:test:cider/nrepl
What happens if you copy the command and run it in the terminal? (remember to cd to the project dir first) You might see more output there

Zachary04:10:56

When running in terminal, getting back a nREPL server started on port 63921 on host localhost - ,

vemv04:10:41

Did it output anything else? Does its classpath include mx.cider stuff?

Zachary04:10:04

No other output

vemv05:10:39

In specific terms, if you ps aux | grep java you should see items like • --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED.cache/mx.cider/enrich-classpath/1601/707673445/3456644593.jar/Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home/lib/src.zip If they're there, it suceeded; if not, fallback logic was applied

Zachary05:10:15

Ok, none of those are showing in the output

vemv05:10:21

Thanks. I'd recommend to temporarily modify clojure.sh to debug info Specifically, you can add: cat $output > foo.txt and share it as a Gist

Zachary05:10:25

I’m looking at clojure.sh in the latest cider directory. Anywhere I should be adding that line?

vemv05:10:30

output=$(2>&1 "$clojure" -Sforce -Srepro -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.main.report=stderr -Sdeps '{:deps {mx.cider/tools.deps.enrich-classpath {:mvn/version "1.18.1"}}}' -M -m cider.enrich-classpath.clojure "$clojure" "$here" "true" "$@")
  cat $output > foo.txt

Zachary05:10:19

Added that to line 41 of the clojure.sh it didn’t output anything to file that I can tell, but is outputting to terminal:

vemv05:10:22

my bad, it should have been echo instead of cat

Zachary05:10:36

hmmm…. not seeing any *.txt. It should be where the bash script is, in the cider directory, right?

vemv05:10:41

mmm, make it an absolute path to be sure

Zachary05:10:53

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See  for further details. [:cider.enrich-classpath/classifiers #{"sources" "javadoc"}] Completed in 0.00 minutes. clojure.lang.ExceptionInfo: Could not find artifact bouncycastle:bctsp-jdk14:jar:138 in central () {:lib bouncycastle/bctsp-jdk14, :coord {:mvn/version "138", :deps/manifest :mvn, :dependents [com.lowagie/itext], :parents #{[incanter/incanter-pdf com.lowagie/itext]}}} at clojure.tools.deps.extensions.maven$get_artifact.invokeStatic(maven.clj:167) at clojure.tools.deps.extensions.maven$get_artifact.invoke(maven.clj:155) at clojure.tools.deps.extensions.maven$eval3286$fn__3289.invoke(maven.clj:178) at clojure.lang.MultiFn.invoke(MultiFn.java:244) at clojure.tools.deps$download_libs$fn__2864$fn__2865.invoke(deps.clj:465) at clojure.lang.AFn.applyToHelper(AFn.java:152) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990) at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990) at clojure.lang.RestFn.invoke(RestFn.java:425) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.RestFn.applyTo(RestFn.java:132) at clojure.core$apply.invokeStatic(core.clj:671) at clojure.core$bound_fn_STAR_$fn__5818.doInvoke(core.clj:2020) at clojure.lang.RestFn.invoke(RestFn.java:397) at clojure.lang.AFn.call(AFn.java:18) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1623) /opt/homebrew/bin/clojure "-A:dev/reloaded:portal" "-Sdeps" "{:deps {nrepl/nrepl {:mvn/version \"1.0.0\"} cider/cider-nrepl {:mvn/version \"0.39.0\"} refactor-nrepl/refactor-nrepl {:mvn/version \"3.9.0\"}} :aliases {:cider/nrepl {:main-opts [\"-m\" \"nrepl.cmdline\" \"--middleware\" \"[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]\"]}}}" "-M:dev/reloaded:cider/nrepl"

vemv05:10:01

Interesting... that's our issue Does your deps.edn define a special Maven repo where bouncycastle:bctsp-jdk14:jar:138 should be fetched from?

Zachary05:10:54

I don’t think soo…. It’s sort of a catch-all project for me to test out a bunch of different stuff

1
vemv05:10:23

Is it a deps.edn that you can share?

Zachary05:10:36

Oh, lol… everything is working on other projects… yeah… very cool… but also… weird

Zachary05:10:50

I’d be embarrased to, but yeah no problem lol

😄 1
Zachary05:10:17

{:paths ["src" "resources"]
 :deps {org.clojure/clojure    {:mvn/version "1.11.1"}
        org.clojure/core.async {:mvn/version "1.6.673"}
        org.clojure/math.combinatorics {:mvn/version "0.2.0"}

        com.rpl/specter        {:mvn/version "1.1.4"}
        criterium/criterium    {:mvn/version "0.4.6"}
        metosin/malli          {:mvn/version "0.11.0"}
        meander/epsilon        {:mvn/version "0.0.650"}

        org.clj-commons/digest {:mvn/version "1.4.100"}
        org.clojure/data.zip   {:mvn/version "1.0.0"}
        org.clojure/data.json  {:mvn/version "2.4.0"}

        aero/aero              {:mvn/version "1.1.6"}
        com.xtdb/xtdb-core     {:mvn/version "1.23.1"}
        com.xtdb/xtdb-rocksdb  {:mvn/version "1.23.1"}
        cheshire/cheshire      {:mvn/version "5.10.0"}

        http-kit/http-kit      {:mvn/version "2.7.0-alpha4"}
        clj-http/clj-http      {:mvn/version "3.12.3"}
        aleph/aleph            {:mvn/version "0.6.1"}
        manifold/manifold      {:mvn/version "0.4.0"}

        ;; bouncycastle/bcprov-jdk16-nosign {:mvn/version "140"}
        org.clojure/java.data  {:mvn/version "1.0.95"}

        incanter/incanter      {:mvn/version "1.9.3"
                                :exclusions [com.lowagie/itext]}

        tesser.core/tesser.core {:mvn/version "1.0.6"}

        org.mentat/emmy         {:mvn/version "0.31.0"}

        techascent/tech.ml.dataset     {:mvn/version "7.000-beta-35"}
        techascent/tech.ml.dataset.sql {:mvn/version "6.046-01"}
        techascent/tech.ml             {:mvn/version "6.019"}
        techascent/tech.io             {:mvn/version "4.30"}

        com.cnuernber/ham-fisted {:mvn/version "1.000-beta-97"}
        com.climate/claypoole    {:mvn/version "1.1.4"}

        ;; scicloj/scicloj.ml         {:mvn/version "0.2.2"}
        scicloj/tablecloth     {:mvn/version "7.000-beta-27"}

        net.clojars.wkok/openai-clojure {:mvn/version "0.5.1"}

        org.apache.commons/commons-lang3 {:mvn/version "3.12.0"}

        ;; for parquet
        ;; 
        org.apache.parquet/parquet-hadoop
        {:mvn/version "1.12.0"
         :exclusions [org.slf4j/slf4j-log4j12]}

        org.apache.hadoop/hadoop-common
        {:mvn/version "3.3.0"
         :exclusions  [com.sun.jersey/jersey-core
                       com.sun.jersey/jersey-json
                       com.sun.jersey/jersey-server
                       com.sun.jersey/jersey-servlet

                       dnsjava/dnsjava

                       org.eclipse.jetty/jetty-server
                       org.eclipse.jetty/jetty-servlet
                       org.eclipse.jetty/jetty-util
                       org.eclipse.jetty/jetty-webapp

                       javax.activation/javax.activation-api
                       javax.servlet.jsp/jsp-api
                       javax.servlet/javax.servlet-api

                       io.netty/netty-codec
                       io.netty/netty-handler
                       io.netty/netty-transport
                       io.netty/netty-transport-native-epoll

                       org.codehaus.jettison/jettison

                       org.apache.zookeeper/zookeeper

                       org.apache.curator/curator-recipes
                       org.apache.curator/curator-client
                       org.apache.htrace/htrace-core4

                       org.apache.hadoop.thirdparty/hadoop-shaded-protobuf_3_7
                       org.apache.hadoop/hadoop-auth

                       org.apache.kerby/kerb-core

                       commons-cli/commons-cli
                       commons-net/commons-net
                       org.apache.commons/commons-lang3
                       org.apache.commons/commons-text
                       org.apache.commons/commons-configuration2

                       com.google.re2j/re2j
                       com.google.code.findbugs/jsr305

                       com.jcraft/jsch

                       log4j/log4j
                       org.slf4j/slf4j-log4j12]}
        ;; We literally need this for 1 POJO formatting object.
        org.apache.hadoop/hadoop-mapreduce-client-core
        {:mvn/version "3.3.0"
         :exclusions  [org.slf4j/slf4j-log4j12
                       org.apache.avro/avro
                       org.apache.hadoop/hadoop-yarn-client
                       org.apache.hadoop/hadoop-yarn-common
                       org.apache.hadoop/hadoop-annotations
                       org.apache.hadoop/hadoop-hdfs-client
                       io.netty/netty
                       com.google.inject.extensions/guice-servlet]}
        ;; M-1 mac support for snappy
        org.xerial.snappy/snappy-java {:mvn/version "1.1.8.4"}

        ;; --------------------------------------------------
        ;; arrow deps
        org.apache.arrow/arrow-vector
        {:mvn/version "6.0.0"
         :exclusions [commons-codec/commons-codec
                      com.fasterxml.jackson.core/jackson-core
                      com.fasterxml.jackson.core/jackson-annotations
                      com.fasterxml.jackson.core/jackson-databind
                      org.slf4j/slf4j-api]}
        com.cnuernber/jarrow   {:mvn/version "1.000"}
        ;; --------------------------------------------------
        io.github.nubank/morse {:git/tag "v2023.04.27.01" :git/sha "7a85e46"}
       ;;io.github.discourje/development (:git/sha "817e0696aaefa9551caa190943e39bb8220a9100")
        com.clojure-goes-fast/clj-async-profiler {:mvn/version "1.0.4"}
        djblue/portal          {:mvn/version "0.38.0"}}
 :aliases
 {:run-m {:main-opts ["-m" "karma3.covalent"]}
  :run-x {:ns-default karma3.covalent
          :exec-fn greet
          :exec-args {:name "Clojure"}}
  :build {:deps {io.github.seancorfield/build-clj
                 {:git/tag "v0.8.2" :git/sha "0ffdb4c"
                  ;; since we're building an app uberjar, we do not
                  ;; need deps-deploy for  deployment:
                  :deps/root "slim"}}
          :ns-default build}

  :test {:extra-paths ["test"]
         :extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
                      io.github.cognitect-labs/test-runner
                      {:git/tag "v0.5.0" :git/sha "48c3c67"}}}}}

vemv05:10:51

Thanks much! I have an approximate idea of how to improve things, with the deps.edn it should be even easier Feel free to give any other feedback in the projects where this is working

Zachary05:10:29

haha, will do, glad I could provide something 🙂

🍻 2
Akiz06:10:46

No, or rather - I don’t see how I managed to get the overlay stuck in this position. I’ve played with it now and it mostly gets stuck in the original position. But that’s the problem 🙂. If you can create a ticket, that’s great. I recorded a video here of me playing around with it. If I figure out how to reproduce the weird position, I’ll add info. https://www.loom.com/share/4b2096a56d134fc386a9640cb1573417

vemv11:10:44

Are you able to use the completing-read , i.e. the prompt that asks you for a class?

Akiz12:10:52

When I selected the prompt and pressed enter, the candidate was not completed and the corfu pop-up got stuck. Anyway, suddenly I don’t have a prompt, I don’t understand why. The only thing I did was that I removed orderless from the cider.

Akiz17:10:18

@U45T93RA6 i tried to reproduce it but i dont know where to start to get prompt back.

vemv21:10:48

I'll create an issue in corfu tomorrow.

vemv11:10:57

I've created an issue in Robe (its author is the Company author, and Corfu uses Company-specific properties like :company-doc-buffer) Both Company's author and me agree that things are not ideal, which also ultimately affect Corfu. I proposed a way forward here https://github.com/dgutov/robe/issues/144#issuecomment-1773761965 With an improvement like that, Corfu could just add the improved Company 'api' and the issue would disappear.

vemv11:10:29

...I'd much prefer to ask the Corfu maintainer 'use this new option' instead of 'fix this edge case'. Taking a look at the history of its issue tracker, I was pretty afraid that the latter would not have succeeded.

vemv18:10:11

Feedback will be extremely appreciated before we call this CIDER 1.8.0!

Karl Xaver13:10:50

Unsure if that's ciders fault, but I noticed that completing

(.| "")
fails when completion-styles is set to partial-completion, substring or flex --> the only candidate is ".." orderless, initials --> 700+ unrelated completions And trying it with
(Thread/|)
I get "no match" for all of them. It only seems to work properly with the basic / emacsXX completion-styles, so this fixed it for me:
(add-to-list 'completion-category-overrides '(cider (styles basic)))

vemv13:10:01

https://github.com/clojure-emacs/cider/issues has a couple pinned issues related to completion styles. I never faced an issue related to completion styles (I simply leave them unconfigured - using Emacs 27 here) so I can't relate much at the moment. If it's working properly, that great news. We'd certainly appreciate extra input in those pinned issues, so that we can make a fully informed decision.

Karl Xaver13:10:39

Aye, will look into these issues. If my experience is not an isolated one (I tried it in plain emacs 29.1), a lot of people will run into this. Basically everyone who customized completion-styles in any way, e.g. all the Doom Emacs and "vertico/orderless/embark/..."-stack folks. And for many (like me) it might go unnoticed for quite some time, especially if they also have lsp running. I didn't even know how awesome Ciders completions can be! Thanks a ton for that :) To repro, something like (setq completion-styles '(flex initials partial-completion)) should do it.

👀 1
vemv12:10:17

Thanks! I've created https://github.com/clojure-emacs/cider/pull/3504 with your suggested fix. Of course, ideally we'd support orderless proper, but it's what we have the capacity for atm. (a PR in that direction would be, of course, welcome)

vemv09:10:43

It's merged. Note that flex needs an additional setting https://docs.cider.mx/cider/usage/code_completion.html#completion-styles