Fork me on GitHub

hello, i'm trying to import some java lib at clojure code and i'm using emacs, someone knows how could I see javadoc or parameters from those function at java code that I'm importing into my clojure code. I already tried with clojure-lsp but they don't have support yet to this. Does anyone know if cider do this?


Yes, CIDER will give you autocompletion and parameter signatures for java code.


could I go to definition inside java lib import it on clojure code?


I'm working with jgit java and would like to go to some definition inside java lib, like intellij do. Is this possible with emacs doom?


yes, 100%, javadocs and sources. You'd have to enable this option It only works for Lein projects. It's disabled by default because in big projects, occasionally it can create issues. Both things will be fixed in the next major CIDER release

👍 1

For Java open source projects, I download the source code for the project and add the Java source code to the classpath. (I think this is what the enrich paths function does in the background) I use Clojure CLI and add the Java source code via an alias, adding an :extra-paths that points to the Java source directory or zip archive

👍 1

nice, i will try it.


@U05254DQM this is my deps.edn, i'm trying go to jgit definitions, but jump to definition did not work. Even doc about the function/classes. I put extra-paths with the jgit source code.

{:paths     ["src"]
 :mvn/repos {"jgit-repository" {:url ""}}
 :deps      {org.clojure/clojure               {:mvn/version "1.10.2"}
             org.clojure/data.json             {:mvn/version "1.1.0"}
             org.clojure/tools.logging         {:mvn/version "1.2.4"}
             clj-jgit/clj-jgit                 {:mvn/version "1.0.2"
                                                :exclusions  [org.eclipse.jgit/org.eclipse.jgit.gpg.bc]}
             clucie/clucie                     {:mvn/version "0.4.2"}
             environ/environ                   {:mvn/version "1.2.0"}
             middlesphere/clj-compress         {:mvn/version "0.1.0"}
             talltale/talltale                 {:mvn/version "0.4.3"}
             org.eclipse.jgit/org.eclipse.jgit {:mvn/version ""}}
 :aliases   {:run     {:ns-default chrondb.core
                       :exec-fn    chrondb.core/-main}
             :extra-paths ["/Users/matheusfrancisco/m/dev/jgit"]
             :test    {:extra-paths ["test"]
                       :extra-deps  {clj-kondo/clj-kondo {:mvn/version "2022.02.09"}
                                     {:git/url ""
                                      :sha     "76568540e7f40268ad2b646110f237a60295fa3c"}}
                       :main-opts   ["-m" "cognitect.test-runner" "-d" "test"]}
             :depstar {:extra-deps {seancorfield/depstar {:mvn/version "2.0.171"}}}
             :uberjar {:replace-deps {seancorfield/depstar {:mvn/version "2.0.171"}}
                       :name         "chrondb-standalone.jar"
                       :exec-fn      hf.depstar/uberjar
                       :exec-args    {:aot        true
                                      :jar        "chrondb.jar"
                                      :main-class "chrondb.core"
                                      :sync-pom   true}}}} 


with project.clj adding the jgit to dependencies it work, but needs to type (.org.eclipse.jgit.lib.Repository) the whole path to goto definition work.


with deps.edn I couldn't be able yet to config this on emacs


@UL618PRQ9 To include the Java standard library sources, I create an alias as follows (with the zip of the sources manually downloaded to the path specified)

   {openjdk/java-sources {:local/root "/usr/lib/jvm/openjdk-17/lib/"}}}


I believe you should just need to move the jgit :extrapaths into the :run alias scope in the deps.edn file above

:run {:extra-paths ["/Users/matheusfrancisco/m/dev/jgit"]
      :ns-default chrondb.core
      :exec-fn    chrondb.core/-main}


Or probably they need to be a :local/root to work (I havent tried just using the path), so that would then be

:run {:extra-deps {jgit/src {:local/root "/Users/matheusfrancisco/m/dev/jgit"}}
      :ns-default chrondb.core
      :exec-fn    chrondb.core/-main}


The jgit sources can be cloned from the Eclipse foundation Git service I assume the sources are not distributed in the jar files obtained from the Eclipse Maven repository, so should be downloaded separately.

git clone  /Users/matheusfrancisco/m/dev/jgit

👍 1

I made an example project here: There are several sub projects under the cloned repository above (I dont know if they are all needed). If other sub-projects are needed, then add an :extra-deps for each sub-project. In the jgit-hack project it only includes org.eclipse.jgit, so that is probably the only functions that will auto-complete and for which cider-find-var command will work. cider-find-var need a running repl process and at least one namespace from the clojure project to be evaluated (standard Cider function behaviour)

❤️ 2
thanks3 2

i tried with your repo, thanks a lot , it worked very well with deps.edn

👍 1