Fork me on GitHub

Just to be sure I'm not missing anything - does Cider currently offer any way to view the constructor types or arguments for a Java interop form? eg.

(Classname. ,,,) 
cider-doc and eldoc don't appear to display any relevant information.


More concretely, something like (Integer. 1.0) throws the error "No matching ctor found" without any hint of what ctors it's matching against, and I end up having to leave Emacs and trawl through Javadocs to figure out what what the constructors and argument types are.


@qythium This certainly worked at some point - you’d get all the constructors in the eldoc.


What’s your JDK? Many Java-related things broke after Java 8 because of the modules system.


I'm using jdk 11


Can you check if this works differently with JDK 8?


I'm not sure if that ever worked or not; I guess I'm looking at constructors very infrequently. @qythium for your particular case it could be better to look at static methods just typing Integer/, pressing TAB for autocomplete and "showing javadoc" via Shift+K (in Spacemacs) works for me (parameters are shown, not actual javadoc). @bozhidar It's true that lot of things (like javadoc and source code navigation) broke after switch to JDK >8; It would be nice to know if there are any future plans to address this soon since JDK 8 has become quite old at this point 🙂


@jumar Plans I have plenty, but with so many projects that I’m juggling I’m certainly short on time. 🙂


Nope, doesn't work with JDK 8 either on my end


@jumar K (cider-doc) -> show javadoc works for certain builtin classes but not external libraries, and it opens in a separate web browser app


Mine shows inline docs, it's not the same as standard javadoc function; That's also why it works for some external libs - they are defined here:


Do you know the Emacs command name for that? M-x cider-javadoc?


or is it that you have URLs set to open within Emacs, using EWW or something?


I think it's just cider-doc


Does it work on anyone else's setup? If it's a missing feature I could open an issue in the relevant GH repo (orchard / cider-nrepl)


For external classes you have to have the source jars on your classpath.


(regardless of the JDK version)


Meaning jars that were downloaded from Maven and which I can import from my repl?


Some external libraries work but not others, I guess not every package has a generated javadocs website (not sure how that works)


when I use projectile-toggle-between-implementation-and-test to switch between test and src file. I got: No matching test file found for project type ’generic


any thing I need to configure for that ?


found this: projectile-register-project-type . maybe I should tweak it.


Are you in a lein / deps project?


I see. projectile tells the project type on the top level project.clj


.projectile subfoler/project.clj


this wont do it.


I am in the middle of (apply |caret| str (reverse “asdf”))


what function should I invoke to evaluate the (apply str (reverse “asdf”)) .


cider-eval-sexp-at-point . evaluates “apply”


@i to get projectile to work with a mono-repo (multiple clojure projects within a project) I used the following .dir-locals.el file This enables projectile to toggle between implementation and test correctly. It should work for both deps and leiningen projects


You can change nil to clojure-mode if you want to limit the scope to clojure (something I forgot to do). I dont think it causes any side effects as it is anyway.


@i you wish to evaluate the top level expression, so its cider-eval-defun-at-point or as its on the same line, you could also do cider-eval-sexp-end-of-line but the defn command is generally more useful.


(defn reverse-string [s] ;; <- arglist goes here ;; your code goes here (apply <caret> str (reverse “asdf”)))


neither of the two functions evaluates the (apply str (reverse “asdfasf”)) stuff


I made my own wrapper for this purpose - basically (up-list) then (cider-eval-last-sexp)


@i those functions work for the original question you asked. Now you have changed the code by wrapping it in a defn. I dont understand what you are trying to do now, there is no point wrapping it in a defn if you are not using the argument received by the defn. Replace the "asdf" with s (a terrible arg name by the way) and then just write an expression to call the defn and evaluate that. (reverse-string "asdf") . Using eval-defn works with this expression and is what your tests will do (I assume you doing the exercism challenge this comes from)


and you just put that at the root of the monorepo? much nicer than running touch .projectile on all my subprojects


Yes, having one .dir-locals.el worked more effectively for me than the .projectile files.

bowie 4

works like a charm! awesome trick


i put a dummy project.clj at . the top level.


@jr0cket thanks. especially for your website docs.

👍 4

after doing a bit of hacking around in I found the following to work in both cider-doc and eldoc:

(in-ns ' ;; or replace with your corresponding inlined ns

(reset! cache {})

(defn type-info
  "For the class or interface symbol, return Java type info. If the type has
  defined contructors, the line and column returned will be for the first of
  these for more convenient `jump` navigation."
  (let [info       (class-info class)
        ctors      (vals (get-in info [:members class]))
        first-ctor (->> ctors
                     (sort-by :line)
                     (filter :line)
    (-> info
      (dissoc :members)
      (assoc :arglists
        (map #(if (:argnames %)
                (mapv (fn [n t] (symbol (str t " " n))) (:argnames %) (:argtypes %))
                (:argtypes %)) ctors))
      (merge (select-keys first-ctor [:line :column])))))


@qythium I think it’s best to submit this as GH ticket/PR, so it’s easier to discuss the code there. Slack is poorly suited for this purpose IMO. 🙂


done as a draft PR :)


I'm probably doing something questionable by constructing a symbol with a space in it.. I wonder how else to represent both the type and arg name


Would appreciate if someone could help test this out informally before I package it into a PR for orchard - my JVM knowledge is pretty minimal and I could be missing something


I think I have asked this question before, but can't remember the answer. I installed a local version of nrepl via lein install and now removed it from ~/.m2/... but when I jack in it still says nREPL 0.7.0-alpha3.


@finn.volkel You need to update your CIDER snapshot.


CIDER specifies the version of nREPL to use internally if you’re using cider-jack-in.


What exactly do you mean? I upgraded cider today actually, am now on 0.25.0snapshot.


See cider-nrepl-required-version. CIDER plugs this into the command it uses to start the server.


thanks, it's now on the correct version. I don't know what I did, but today it's the correct verison.


@finn.volkel sounds like you have nrepl version set in Leiningen profil


Having trouble with Spacemacs. Has been working great for the last 2 years or so but today, for some reason, my `*cider-repl*` buffer stopped launching for no reason that I have been able to discover. I've tried multiple launching different projects, thinking maybe there was something in the configuration of a specific project, which did not work. I've tried creating a new project, which also did not work. I moved my previous `.emacs.d` folder to a backup location and create a fresh install of Spacemacs but no luck. Here is the tall end of the `*Messages*` buffer for the fresh install


Done (Total of 1 file compiled, 2 skipped)
(Spacemacs) --> installing package: [email protected] [155/155]
Auto-evilification could not remap these functions in map 'edebug-mode-map':
   - 'edebug-Go-nonstop-mode' originally mapped on 'G'
Auto-evilification could not remap these functions in map 'tar-mode-map':
   - 'tar-chgrp-entry' originally mapped on 'G'
(Spacemacs) Warning: tern binary not found!
Loading /Users/marcusoladell/.emacs.d/layers/+distributions/spacemacs-base/keybindings.el (source)...done
Loading /Users/marcusoladell/.emacs.d/layers/+source-control/version-control/keybindings.el (source)...done
Loading /Users/marcusoladell/.emacs.d/.cache/recentf...done
Saving file /Users/marcusoladell/.spacemacs...
Wrote /Users/marcusoladell/.spacemacs [2 times]
Spacemacs is ready.
Open the quickhelp.
Start checking for new version...
Spacemacs is up to date.
[yas] Check your `yas-snippet-dirs': /Users/marcusoladell/.emacs.d/elpa/yasnippet-20200329.1434/snippets is not a directory
[yas] Prepared just-in-time loading of snippets with some errors.  Check *Messages*.
[nREPL] Starting server via /usr/local/bin/lein update-in :dependencies conj \[nrepl\ \"0.7.0\"\] -- update-in :plugins conj \[refactor-nrepl\ \"2.5.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.0-SNAPSHOT\"\] -- repl :headless :host localhost
[nREPL] Starting server via /usr/local/bin/lein update-in :dependencies conj \[nrepl\ \"0.7.0\"\] -- update-in :plugins conj \[refactor-nrepl\ \"2.5.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.0-SNAPSHOT\"\] -- repl :headless :host localhost
<left-fringe> <drag-mouse-1> is undefined


Many of these warnings or errors I have seen before things went sideways today. Not sure if they are relevant to what is happening. The `nrepl-server` launches successfully. I just don't get any `*cider-nrepl*` buffer connected to it. 😕


I don’t see any CIDER-specific errors in the log you’ve posted. You might want to check


Does your code compiles sucessfully?


I've noticed sometimes launching nRepl when your source is broken makes it crash


Well, might not be nRepl, but lein repl


It does. in the end, it was a versioning issue with various pieces of the middleware.


(originally posted this to #spacemacs but seems more appropriate here)