Fork me on GitHub
#cider
<
2022-02-28
>
lassemaatta08:02:57

does cider offer anything equivalent to stub generation in cursive?

magnars08:02:18

I'm not sure what stub generation in cursive is, but based on the name, is this what you are looking for? https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-add-stubs

lassemaatta08:02:35

> There are still some cases that are impossible for Cursive to analyse the source, for example when vars are dynamically created at runtime, or in cases such as Datomic which are distributed without source at all. For these cases, Cursive supports stub generation. This will run a process and load the problematic namespaces into it, introspect the var metadata and then generate source files containing empty function stubs which it can index for use in the editor.

magnars08:02:10

CIDER doesn't do static analysis, so I don't see what an equivalent would be.

lassemaatta08:02:44

I guess enrich-classpath is vaguely similar, except here we don't have any premade foo-sources.jar to download and display

dpsutton04:03:24

I'm still confused by this. Clojure queries namespace vars at runtime and does not require static analysis. Thus there is no need for a stub to provide the vars from a namespace, since (ns-vars the-ns) will provide the actual vars

lassemaatta04:03:07

the actual reason for asking about this feature is simple: I want to see the function/var docstrings in emacs.

dpsutton04:03:08

CIDER should 100% be able to do this with no extra tooling or stub generation

1
dpsutton04:03:31

CIDER just queries the runtime for the information. As long as those namespaces are loaded it should work

lassemaatta05:03:52

ah, interesting. I'll admit, I'm not always certain what functionality in emacs is provided by cider and what comes from other packages (e.g. clojure-lsp).

dpsutton05:03:41

they both will provide this functionality, but with two different philosophies. CIDER requires a running repl and queries the runtime for information. In Clojure this is surprisingly sufficient. Clojure-lsp (and Cursive) use static analysis and do not require a running repl. This has benefits, but has the downside that if the source is obfuscated (eg, Datomic) it has nothing to reason about and cannot offer any information

vemv06:03:42

(-> #'+ meta :doc) should be enlightening :) that's basically what CIDER does