I'm trying out nvim with lazyvim, Conjure, and clojure-lsp. I'm working on a datomic project and it's not showing any docs or autocompletion for it, but normal things ok. I recall needing to enable stub generation for datomic.api so I added that config and it says it's generating stubs, but the stubs dir is empty when it is complete. What might be going wrong here?
yes, datomic.api is closed source so stubs are required. hum, try check server logs to see if mentions the stub generation state
If you see the progress message about stub generation it's because it found stubs to be generated, like datomic.api for example
Hmm, unfortunately I'm a neovim noob so I'm not sure how to check the logs there
I don't have any issues with the same project in Calva, but I believe Calva does something under the hood to detect that sort of thing without specifying a config.
I doubt, calva has no stub builtin support AFAIK
unless it's using nrepl to navigate or get info from the symbol
I'm not sure what Calva does, but I am sure that I didn't have a stub config before and it worked
yeah, probably not using LSP.
Anyway, the server logs should help, also clean any .lsp cache before
cmp-conjure is working since it uses the repl, but when I try to configure both clojure-lsp takes over the completions and docs
The lsp config I'm using is from the docs: {:stubs {:generation {:namespaces #{"datomic.api"}}}}
I have tried clearing the cache
that looks correct
We will need to check server logs
try following what I mentioned in the link
Checking that now
Ok so it's looking for portal, which I have included as a dev alias and it's not on the classpath yet since the repl hasn't started when it is analyzing
I have portal set up in user.clj automatically
wait where/when it's looking for portal? I don't get it why it's related with stubs. Maybe post the logs here
2025-08-21T15:48:40.320Z INFO [clojure-lsp.feature.stubs:36] - [stub] Generating stubs for analysis for namespaces #{"datomic.api"} on .lsp/.cache/stubs
2025-08-21T15:48:43.793Z INFO [clojure-lsp.feature.stubs:37] - :stub/generate 3474ms
2025-08-21T15:48:43.794Z ERROR [clojure-lsp.feature.stubs:76] - [stub] Generation failed.Exception in thread "main" Syntax error macroexpanding at (user.clj:1:1).
at clojure.lang.Compiler.load(Compiler.java:8223)
at clojure.lang.RT.loadResourceScript(RT.java:401)
at clojure.lang.RT.loadResourceScript(RT.java:388)
at clojure.lang.RT.maybeLoadResourceScript(RT.java:384)
at clojure.lang.RT.doInit(RT.java:506)
at clojure.lang.RT.init(RT.java:487)
at clojure.main.main(main.java:38)
Caused by: java.io.FileNotFoundException: Could not locate portal/api__init.class, portal/api.clj or portal/api.cljc on classpath.
at clojure.lang.RT.load(RT.java:482)
at clojure.lang.RT.load(RT.java:444)
at clojure.core$load$fn__6933.invoke(core.clj:6189)
at clojure.core$load.invokeStatic(core.clj:6188)
at clojure.core$load.doInvoke(core.clj:6172)
at clojure.lang.RestFn.invoke(RestFn.java:411)
at clojure.core$load_one.invokeStatic(core.clj:5961)
at clojure.core$load_one.invoke(core.clj:5956)
at clojure.core$load_lib$fn__6875.invoke(core.clj:6003)
at clojure.core$load_lib.invokeStatic(core.clj:6002)
at clojure.core$load_lib.doInvoke(core.clj:5981)
at clojure.lang.RestFn.applyTo(RestFn.java:145)
at clojure.core$apply.invokeStatic(core.clj:669)
at clojure.core$load_libs.invokeStatic(core.clj:6044)
at clojure.core$load_libs.doInvoke(core.clj:6028)
at clojure.lang.RestFn.applyTo(RestFn.java:140)
at clojure.core$apply.invokeStatic(core.clj:669)
at clojure.core$require.invokeStatic(core.clj:6066)
at clojure.core$require.doInvoke(core.clj:6066)
at clojure.lang.RestFn.invoke(RestFn.java:706)
at user$eval136$loading__6814__auto____137.invoke(user.clj:1)
at user$eval136.invokeStatic(user.clj:1)
at user$eval136.invoke(user.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:7739)
at clojure.lang.Compiler.eval(Compiler.java:7728)
at clojure.lang.Compiler.load(Compiler.java:8211)
... 6 moreI have a portal alias so when I start a repl I use -A:dev:portal
The dev alias includes the sources under /dev, which currently is just the user.clj
hum, interesting
so it should be more a bug in https://github.com/clj-easy/stub
that I created 😅
actually no sure, because clojure-lsp pass the classpath https://github.com/clojure-lsp/clojure-lsp/blob/f5cab6c31c834e850f1b1993c6ff0cba78e0ae9d/lib/src/clojure_lsp/feature/stubs.clj#L41
so it should be passing with portal in classpath
not sure why that is failing
I tried adding :source-aliases #{:src :dev :portal} and it now loads up portal, but still nothing generated
And no error
oh, interesting
ok, progress
2025-08-21T15:57:59.869Z INFO [clojure-lsp.feature.stubs:36] - [stub] Generating stubs for analysis for namespaces #{"datomic.api"} on .lsp/.cache/stubs
2025-08-21T15:58:21.280Z INFO [clojure-lsp.handlers:330] - :lsp/document-highlight 0mstry clean .lsp/.cache , not sure it's a cache issue
I'm doing that each iteration
so after that log nothing on .lsp/.cache/stubs ?
Yep, nothing
try removing the global cache ~/.cache/clojure-lsp/
After doing that it took a long time analyzing JDK sources and still no stubs
2025-08-21T16:05:49.586Z INFO [clojure-lsp.feature.java-interop:321] - [java] JDK source analyzed and cached successfully.
2025-08-21T16:05:49.586Z INFO [clojure-lsp.feature.stubs:36] - [stub] Generating stubs for analysis for namespaces #{"datomic.api"} on .lsp/.cache/stubsSame log
Oh wait
It's still saying Generating stubs
yeah, the bad thing is that the first time stubs generation may take even couple of mins
not sure why
Ok waiting for it
Hopefully it's good this time
🤞
it's a feature we could improve even more
10 minutes already and still generating
On a M1 Max MBP
hum weird
Maybe it's hanging at this point
yeah, maybe you could log the stub command used for debugging 🤔
clojure-lsp is installed via mason so I'm not sure how I would do that
Derp
I feel dumb
My user.clj also tries to connect to datomic automatically for development and it wasn't running. I removed the :dev namespace from the config and now it doesn't load portal, but still has access to portal and the stubs are there
hum, yeah that should help
maybe is related with a huge classpath?
It's a small classpath
Just was stuck trying to connect, but no logging of that
So the stubs are there, but I still don't get docs and completion
oh, if they are there clojure-lsp should consider them indeed
we need to improve this whole stub thing debugging
It's possible there's something off in my neovim config. It's been throwing me for loops for days
I'm trying to keep the config as simple as possible using lazyvim
Hum, it should not be related with clojure-lsp I believe
I mean, it should not affect it
I'm at a loss here
Maybe I should just stick to Calva
This is the stuff that drives me nuts with nvim and emacs
Calva just delegates to cider-nrepl which is the same base for emacs and vim, so you could leverage stubs from them too
I just don't understand why it's not working with what I have. I'm following the recommended setup from Conjure
Which uses cider
When I don't include clojure-lsp then cmp-conjure works for datomic while the repl is running, but when I include clojure-lsp then cmp-conjure isn't included in the completions
yeah, I never used stubs or these things from cider, so not sure too how it works
yeah, sounds like there must be a way to check if LSP returns anything otherwise fallback to repl
calva does that with the repl
It's been suggested to use blink.cmp, but that isn't trivial to configure
At this point I'm not sure that all of this rabbit hole configuration is worth it instead of just using something like Calva that just works out of the box
I used Cursive for the longest, but IntelliJ code quality has dropped off a cliff and has so many bugs now
yeah, I agree stubs and java interop is not the great currently, but other things should work smoothly
I had other issues getting nvim to work as well
Various recommended plugins that haven't been updated in years so it's broken with latest nvim
yeah, havd few experience with nvim, only emacs, just used lazy vim and emacs looks way easier IMO 😅
Haha
I tried emacs via spacemacs and had a tough time
Calva is pretty good tho
Oh for sure. I don't have issues with Calva. I'm just not a huge fan of VSCode, but there aren't really any better alternatives at the moment it seems. Zed looks promising, but isn't there yet
I'd love to continue using IntelliJ, but the bugs and various other issues in it are driving me insane
My recommendation and you probably already heard that: if you wanna look for something as a long term, try doom-emacs hehe
I heard of that, but haven't tried it. How does it differ from vanilla and spacemacs?
IMO it's way more modern, behave close to a IDE like vscode in terms of UI and configuration, but close to spaceemacs
just faster and more modular
I use for 6 years now
Ah, ok. Do you know a guide for getting Clojure working in that?
my config in case you wanna check it: https://github.com/ericdallo/dotfiles/
I wrote https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/, it's a little bit outdated, but most things are just easier nowadays