lsp

mikejcusack 2025-08-20T13:05:30.449459Z

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?

ericdallo 2025-08-21T15:40:13.020719Z

yes, datomic.api is closed source so stubs are required. hum, try check server logs to see if mentions the stub generation state

ericdallo 2025-08-21T15:40:42.472619Z

If you see the progress message about stub generation it's because it found stubs to be generated, like datomic.api for example

mikejcusack 2025-08-21T15:41:19.622429Z

Hmm, unfortunately I'm a neovim noob so I'm not sure how to check the logs there

ericdallo 2025-08-21T15:41:58.750319Z

check if https://clojure-lsp.io/troubleshooting/#server-log

mikejcusack 2025-08-21T15:42:16.977499Z

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.

ericdallo 2025-08-21T15:42:41.154909Z

I doubt, calva has no stub builtin support AFAIK

ericdallo 2025-08-21T15:42:54.645729Z

unless it's using nrepl to navigate or get info from the symbol

mikejcusack 2025-08-21T15:43:15.591229Z

I'm not sure what Calva does, but I am sure that I didn't have a stub config before and it worked

ericdallo 2025-08-21T15:43:36.040849Z

yeah, probably not using LSP. Anyway, the server logs should help, also clean any .lsp cache before

mikejcusack 2025-08-21T15:44:05.213089Z

cmp-conjure is working since it uses the repl, but when I try to configure both clojure-lsp takes over the completions and docs

mikejcusack 2025-08-21T15:44:57.473029Z

The lsp config I'm using is from the docs: {:stubs {:generation {:namespaces #{"datomic.api"}}}}

mikejcusack 2025-08-21T15:45:17.181749Z

I have tried clearing the cache

ericdallo 2025-08-21T15:46:25.716309Z

that looks correct

ericdallo 2025-08-21T15:46:30.466339Z

We will need to check server logs

ericdallo 2025-08-21T15:46:36.024869Z

try following what I mentioned in the link

mikejcusack 2025-08-21T15:46:39.120259Z

Checking that now

mikejcusack 2025-08-21T15:51:06.074859Z

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

mikejcusack 2025-08-21T15:51:53.766029Z

I have portal set up in user.clj automatically

ericdallo 2025-08-21T15:52:38.686289Z

wait where/when it's looking for portal? I don't get it why it's related with stubs. Maybe post the logs here

mikejcusack 2025-08-21T15:53:33.563669Z

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 more

mikejcusack 2025-08-21T15:54:54.978859Z

I have a portal alias so when I start a repl I use -A:dev:portal

mikejcusack 2025-08-21T15:55:42.113859Z

The dev alias includes the sources under /dev, which currently is just the user.clj

ericdallo 2025-08-21T15:56:24.490679Z

hum, interesting

ericdallo 2025-08-21T15:56:49.216039Z

so it should be more a bug in https://github.com/clj-easy/stub

ericdallo 2025-08-21T15:57:00.680769Z

that I created 😅

ericdallo 2025-08-21T15:58:12.319709Z

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

ericdallo 2025-08-21T15:58:25.020509Z

so it should be passing with portal in classpath

ericdallo 2025-08-21T15:58:51.281869Z

not sure why that is failing

mikejcusack 2025-08-21T15:59:26.756769Z

I tried adding :source-aliases #{:src :dev :portal} and it now loads up portal, but still nothing generated

mikejcusack 2025-08-21T15:59:30.263879Z

And no error

ericdallo 2025-08-21T15:59:58.285829Z

oh, interesting

ericdallo 2025-08-21T16:00:05.089909Z

ok, progress

mikejcusack 2025-08-21T16:00:05.412209Z

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 0ms

ericdallo 2025-08-21T16:00:23.090549Z

try clean .lsp/.cache , not sure it's a cache issue

mikejcusack 2025-08-21T16:01:05.932939Z

I'm doing that each iteration

ericdallo 2025-08-21T16:01:28.889819Z

so after that log nothing on .lsp/.cache/stubs ?

mikejcusack 2025-08-21T16:01:38.688269Z

Yep, nothing

ericdallo 2025-08-21T16:01:45.283519Z

try removing the global cache ~/.cache/clojure-lsp/

mikejcusack 2025-08-21T16:06:23.733739Z

After doing that it took a long time analyzing JDK sources and still no stubs

mikejcusack 2025-08-21T16:07:21.254109Z

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/stubs

mikejcusack 2025-08-21T16:07:24.282999Z

Same log

mikejcusack 2025-08-21T16:07:49.369969Z

Oh wait

mikejcusack 2025-08-21T16:08:03.069889Z

It's still saying Generating stubs

ericdallo 2025-08-21T16:09:02.642569Z

yeah, the bad thing is that the first time stubs generation may take even couple of mins

ericdallo 2025-08-21T16:09:05.972129Z

not sure why

mikejcusack 2025-08-21T16:09:16.165859Z

Ok waiting for it

mikejcusack 2025-08-21T16:09:21.544759Z

Hopefully it's good this time

ericdallo 2025-08-21T16:09:44.420339Z

🤞

ericdallo 2025-08-21T16:10:02.027389Z

it's a feature we could improve even more

👍 1
mikejcusack 2025-08-21T16:15:38.969389Z

10 minutes already and still generating

mikejcusack 2025-08-21T16:15:43.791119Z

On a M1 Max MBP

ericdallo 2025-08-21T16:16:14.765329Z

hum weird

mikejcusack 2025-08-21T16:16:30.799939Z

Maybe it's hanging at this point

ericdallo 2025-08-21T16:17:22.934069Z

yeah, maybe you could log the stub command used for debugging 🤔

mikejcusack 2025-08-21T16:21:13.047579Z

clojure-lsp is installed via mason so I'm not sure how I would do that

mikejcusack 2025-08-21T16:23:13.584389Z

Derp

mikejcusack 2025-08-21T16:23:17.652259Z

I feel dumb

mikejcusack 2025-08-21T16:23:55.639889Z

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

ericdallo 2025-08-21T16:24:59.215099Z

hum, yeah that should help

ericdallo 2025-08-21T16:25:09.783869Z

maybe is related with a huge classpath?

mikejcusack 2025-08-21T16:25:21.074999Z

It's a small classpath

mikejcusack 2025-08-21T16:25:28.324959Z

Just was stuck trying to connect, but no logging of that

mikejcusack 2025-08-21T16:25:42.282339Z

So the stubs are there, but I still don't get docs and completion

ericdallo 2025-08-21T16:27:39.601319Z

oh, if they are there clojure-lsp should consider them indeed

ericdallo 2025-08-21T16:27:52.543789Z

we need to improve this whole stub thing debugging

mikejcusack 2025-08-21T16:28:31.050149Z

It's possible there's something off in my neovim config. It's been throwing me for loops for days

mikejcusack 2025-08-21T16:28:48.574629Z

I'm trying to keep the config as simple as possible using lazyvim

ericdallo 2025-08-21T16:32:16.268289Z

Hum, it should not be related with clojure-lsp I believe

ericdallo 2025-08-21T16:32:27.778019Z

I mean, it should not affect it

mikejcusack 2025-08-21T16:33:46.650259Z

I'm at a loss here

😅 1
mikejcusack 2025-08-21T16:37:35.333549Z

Maybe I should just stick to Calva

mikejcusack 2025-08-21T16:37:49.331409Z

This is the stuff that drives me nuts with nvim and emacs

ericdallo 2025-08-21T16:39:47.307969Z

Calva just delegates to cider-nrepl which is the same base for emacs and vim, so you could leverage stubs from them too

mikejcusack 2025-08-21T16:40:59.609259Z

I just don't understand why it's not working with what I have. I'm following the recommended setup from Conjure

mikejcusack 2025-08-21T16:41:06.198259Z

Which uses cider

mikejcusack 2025-08-21T16:41:58.727139Z

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

ericdallo 2025-08-21T16:42:01.554969Z

yeah, I never used stubs or these things from cider, so not sure too how it works

ericdallo 2025-08-21T16:42:22.893459Z

yeah, sounds like there must be a way to check if LSP returns anything otherwise fallback to repl

ericdallo 2025-08-21T16:42:28.088569Z

calva does that with the repl

mikejcusack 2025-08-21T16:43:07.508049Z

It's been suggested to use blink.cmp, but that isn't trivial to configure

mikejcusack 2025-08-21T16:44:05.234649Z

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

mikejcusack 2025-08-21T16:45:09.623169Z

I used Cursive for the longest, but IntelliJ code quality has dropped off a cliff and has so many bugs now

ericdallo 2025-08-21T16:46:36.309479Z

yeah, I agree stubs and java interop is not the great currently, but other things should work smoothly

mikejcusack 2025-08-21T16:47:47.429749Z

I had other issues getting nvim to work as well

mikejcusack 2025-08-21T16:48:10.780209Z

Various recommended plugins that haven't been updated in years so it's broken with latest nvim

ericdallo 2025-08-21T16:48:51.891059Z

yeah, havd few experience with nvim, only emacs, just used lazy vim and emacs looks way easier IMO 😅

mikejcusack 2025-08-21T16:49:11.401699Z

Haha

mikejcusack 2025-08-21T16:49:23.513869Z

I tried emacs via spacemacs and had a tough time

ericdallo 2025-08-21T16:49:40.664499Z

Calva is pretty good tho

mikejcusack 2025-08-21T16:50:17.171179Z

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

mikejcusack 2025-08-21T16:51:00.572489Z

I'd love to continue using IntelliJ, but the bugs and various other issues in it are driving me insane

ericdallo 2025-08-21T16:51:29.474839Z

My recommendation and you probably already heard that: if you wanna look for something as a long term, try doom-emacs hehe

mikejcusack 2025-08-21T16:52:04.204499Z

I heard of that, but haven't tried it. How does it differ from vanilla and spacemacs?

ericdallo 2025-08-21T16:52:31.749169Z

IMO it's way more modern, behave close to a IDE like vscode in terms of UI and configuration, but close to spaceemacs

ericdallo 2025-08-21T16:52:37.528629Z

just faster and more modular

ericdallo 2025-08-21T16:52:49.061909Z

I use for 6 years now

mikejcusack 2025-08-21T16:53:04.172189Z

Ah, ok. Do you know a guide for getting Clojure working in that?

ericdallo 2025-08-21T16:53:15.569529Z

my config in case you wanna check it: https://github.com/ericdallo/dotfiles/

👍 1
ericdallo 2025-08-21T16:53:44.685119Z

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

👍 1