Fork me on GitHub
#cider
<
2020-03-22
>
dpsutton01:03:18

I think that’s fundamentally how cider works. It is part of of running image and doesn’t do any static introspection. Until you evaluate forms it only knows about clojure core essentially.

practicalli08:03:28

@dpsutton It seems I didn't explain clearly. My test was on the slurp function, so not working on clojure.core functions. I don't need to evaluate anything specific, but it seems I need to evaluate something before any function will work with clojure-doc. If it should work on clojure.core, I will do more testing on other core functions. I understand that my own custom functions should be evaluated before Cider can find them.

practicalli11:03:26

@marques.goncalves.fel The following works deps.edn file will jump to Java definitions using the CIDER command clj-find-var . I have a deps.edn as follows:

{:path 
 ["src" "resources"]

 :deps
 {org.clojure/clojure {:mvn/version "1.10.1"}

  ;; Java 11 sources
  java-sources {:local/root "/usr/lib/jvm/openjdk-11/lib/src.zip"}}}
The location of your sources.zip file may differ. I installed the sources from an Ubuntu package openjdk-11-source . I would recommend adding the Java sources as an alias, rather than a main dependency.

practicalli11:03:41

@marques.goncalves.fel I've added example aliases for including java sources in my example deps.edn file here: https://github.com/practicalli/deps-edn-examples/blob/master/deps.edn#L81-L93 I would encourage you to use aliases rather than including sources as a main dependency, as the java sources are a development time artifact.

:java-11-source
  {:extra-deps
   {java-sources {:local/root "/usr/lib/jvm/openjdk-11/lib/src.zip"}}}

Felipe Marques19:03:11

Thanks for the amazing explanation. Normally, I don't have to look the java source code. But recently I have been working with Avro and it is handy to be able to take a look at the library from inside Spacemacs. But now I understand better the internals and how I could make it available. Thanks!

practicalli19:03:42

Its useful stuff for the Spacemacs book I am writing, so I was happy that I managed to figure out how to do it. Occasionally I do a bit of Java Interop, so it is useful to have for those times. Now I know how to do it next time I forget 🙂 https://practicalli.github.io/spacemacs/navigating-code/java-definitions.html

Felipe Marques11:03:24

Cool! Btw, I love you book. I use Spacemacs and it was my go-to reference when I was starting (and it still is!)

practicalli11:03:16

If you always want to include the java sources when running cider-jack-in then you can add a .dir-locals.el file to the root of your Clojure project. Here is an example that will include the java-11-source and use the clojure-cli buld tool by default (if you have more than one build configuration file)

((nil . ((cider-clojure-cli-global-options . "-A:java-11-source")
         (cider-preferred-build-tool . "clojure-cli"))))

borkdude14:03:36

In case there are any nREPL experts in the house, I could use a little help with https://github.com/borkdude/nrepl-server. It doesn't work with lein and boot yet. Somehow the response is not printed

dpsutton15:03:05

@U04V15CAJ just a casual perusal, but I see you're casing on the op code as a keyword. I thought these are always strings. If you don't match anything in the session loop you stop there. Strange to only see a recur in the eval branch

dpsutton15:03:08

and i see the following in nrepl server:

(defn- normalize-msg
  "Normalize messages that are not quite in spec. This comes into effect with
   The EDN transport, and other transports that allow more types/data structures
   than bencode, as there's more opportunity to be out of specification."
  [msg]
  (cond-> msg
    (keyword? (:op msg)) (update :op name)))