Fork me on GitHub
#lsp
<
2022-09-27
>
eccentric J16:09:14

Posted in a similar issue but wouldn't mind some realtime debugging. In short, I'm running a shadow-cljs project with neovim. If I hover over a core function, I don't get much info about it. But if I hover over one of my project functions, I get all the details.

ericdallo16:09:24

That looks like a classpath scan fail. Latest clojure-lsp warns about that fail during start with a option to retry. You can check if that was your case checking the server logs

eccentric J16:09:53

Will look at that now, thanks!

eccentric J17:09:46

Updated my config to log to /tmp/clojure-lsp.out, no classpath error detected

eccentric J17:09:12

2022-09-27T17:08:54.422Z  INFO [clojure-lsp.crawler:70] - [Startup] Project only paths analyzed by clj-kondo, took 150ms
2022-09-27T17:08:54.423Z  INFO [clojure-lsp.dep-graph:300] - :maintain-dep-graph 0ms
2022-09-27T17:08:54.424Z  INFO [clojure-lsp.handlers:107] - [Startup] Analyzing test paths for project root file:///Users/j/projects/crunchy-price-calc
2022-09-27T17:08:54.424Z  INFO [clojure-lsp.feature.clojuredocs:21] - [Clojuredocs] Refreshing clojuredocs cache...
2022-09-27T17:08:54.424Z  INFO [clojure-lsp.handlers:84] - :initialize 424ms
2022-09-27T17:08:54.426Z  INFO [clojure-lsp.feature.java-interop:222] - [Java] JDK source already present on global LSP cache dir.
2022-09-27T17:08:54.427Z  DEBUG [clojure-lsp.server:86] - Publishing 0 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/tasks/build.cljs
2022-09-27T17:08:54.428Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.428Z  DEBUG [clojure-lsp.server:86] - Publishing 1 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/tasks/fetch.cljs
2022-09-27T17:08:54.428Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.429Z  DEBUG [clojure-lsp.server:86] - Publishing 0 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/assets.cljs
2022-09-27T17:08:54.429Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.429Z  DEBUG [clojure-lsp.server:86] - Publishing 14 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/price_calc/app/views.cljs
2022-09-27T17:08:54.429Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.429Z  DEBUG [clojure-lsp.server:86] - Publishing 1 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/price_calc/app/storage.cljs
2022-09-27T17:08:54.429Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.430Z  DEBUG [clojure-lsp.server:86] - Publishing 0 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/price_calc/app/format.cljs
2022-09-27T17:08:54.430Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.430Z  DEBUG [clojure-lsp.server:86] - Publishing 1 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/price_calc/app/core.cljs
2022-09-27T17:08:54.430Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.430Z  DEBUG [clojure-lsp.server:86] - Publishing 0 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/price_calc/root.cljs
2022-09-27T17:08:54.431Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.436Z  INFO [clojure-lsp.server:437] - Initialized!
2022-09-27T17:08:54.530Z  INFO [clojure-lsp.db:67] - [DB] Reading transit analysis cache from /Users/j/.cache/clojure-lsp/db.transit.json db took 104ms
2022-09-27T17:08:54.530Z  DEBUG [clojure-lsp.server:86] - Publishing 0 diagnostics for file:///Users/j/projects/crunchy-price-calc/src/crunchy/price_calc/data/cloud_services.cljs
2022-09-27T17:08:54.530Z  INFO [clojure-lsp.dep-graph:300] - :maintain-dep-graph 0ms
2022-09-27T17:08:54.530Z  INFO [clojure-lsp.server:87] - :publish-diagnostics 0ms
2022-09-27T17:08:54.530Z  INFO [clojure-lsp.feature.java-interop:256] - [Java] JDK source cached loaded successfully.
2022-09-27T17:08:54.579Z  INFO [clojure-lsp.dep-graph:300] - :maintain-dep-graph 0ms
2022-09-27T17:08:54.580Z  WARN [clojure-lsp.kondo:298] - Non-fatal error from clj-kondo: No configs copied.

ericdallo17:09:28

The classpath log should be before those lines šŸ˜… before [Startup] Project only paths analyzed by clj-kondo

eccentric J17:09:34

My mistake! Looking now

eccentric J17:09:52

2022-09-27T17:51:32.104Z  INFO [clojure-lsp.db:67] - [DB] Reading transit analysis cache from /Users/j/projects/crunchy-price-calc/.lsp/.cache/db.transit.json db took 130ms
2022-09-27T17:51:32.130Z  INFO [clojure-lsp.dep-graph:300] - :maintain-dep-graph 26ms
2022-09-27T17:51:32.206Z  INFO [clojure-lsp.crawler:205] - [Startup] Using cached db for project root /Users/j/projects/crunchy-price-calc
2022-09-27T17:51:32.206Z  INFO [clojure-lsp.source-paths:73] - [Startup] Using source-paths from classpath: ["/Users/j/projects/crunchy-price-calc/test" "/Users/j/projects/crunchy-price-calc/src"]
2022-09-27T17:51:32.207Z  INFO [clojure-lsp.crawler:113] - Copying kondo configs from classpath to project if any...
2022-09-27T17:51:32.277Z  WARN [clojure-lsp.kondo:298] - Non-fatal error from clj-kondo: Configs copied:
- .clj-kondo/babashka/sci
- .clj-kondo/funcool/promesa
- .clj-kondo/rewrite-clj/rewrite-clj

2022-09-27T17:51:32.277Z  INFO [clojure-lsp.crawler:115] - Copied kondo configs, took 70ms secs.
2022-09-27T17:51:32.277Z  INFO [clojure-lsp.crawler:237] - [Startup] Analyzing source paths for project root /Users/j/projects/crunchy-price-calc
2022-09-27T17:51:32.278Z  INFO [clojure-lsp.crawler:74] - [Startup] Project only paths analyzed by clj-depend, took 0ms

eccentric J17:09:38

shadow-cljs.edn

{:dependencies
 [[reagent "1.1.1"]
  [funcool/promesa "8.0.450"]
  [zprint "1.2.4"]]

 :source-paths
 ["src"]

 :dev-http {3080 "public"}

 :builds
 {:app {:target     :browser
        :output-dir "public/js"
        :asset-path "/js"
        :modules    {:main             {:entries      [crunchy.price-calc.app.core]
                                        :init-fn      crunchy.price-calc.app.core/main}}
        :release    {:compiler-options {:optimiations :advanced}}}}}

eccentric J17:09:11

deps.edn

{:paths ["src"]
 :deps {funcool/promesa {:mvn/version "8.0.450"}
        reagent/reagent {:mvn/version "1.1.1"}
        zprint/zprint   {:mvn/version "1.2.4"}}}

eccentric J17:09:42

Could it be because I have a deps.edn for kondo, that it's skipping the shadow cljs npx shadow-cljs classpath cmd?

eccentric J18:09:06

Experimented with adding clojurescript to deps.edn. That seemed to have triggered a cache update, as once I restarted neovim I saw the following:

2022-09-27T18:00:12.846Z  DEBUG [clojure-lsp.classpath:115] - Classpath found, paths:  ["test" "src"  ... (goes on for a while)]
2022-09-27T18:00:12.847Z  INFO [clojure-lsp.classpath:103] - Finding classpath via `/Users/j/.asdf/shims/npx shadow-cljs classpath`
2022-09-27T18:00:13.743Z  DEBUG [clojure-lsp.classpath:115] - Classpath found, paths:  ["src" ... (goes on for a while)]

eccentric J18:09:14

Working again

eccentric J18:09:14

Removed the dep and is still working, seems it was just a caching issue of some kind.

ericdallo18:09:55

Humm, yep, for some reason clojure-lsp didn't re-calculate the classpath and was using a old cache, sounds like a bug :thinking_face:

eccentric J18:09:58

Now that that's solved šŸ˜…, how does the clojuredocs integration work? Is that a custom request to clojure-lsp or does it enhance one of those standard lsp server request features?

ericdallo18:09:56

it's a custom request clojure-lsp does after startup and keep cache of whole clojuredocs info :)

eccentric J20:09:03

I see, then provides two possible requests? ā€¢ find-docs-for ā€¢ find-hover-docs-for

eccentric J20:09:56

> Whether to get clojuredocs information on hover, the clojuredocs content is cached. So with the {:hover {:clojuredocs true}} default, it should show clojuredocs content in the textDocument/hover request?

eccentric J17:09:03

With the default settings, seems I only get info from the docstr and signature in hover and not seeing any clojuredocs content there

ericdallo18:09:00

Could you check your server logs for any clojuredocs mention after startup?

eccentric J18:09:05

2022-09-27T18:00:22.580Z  INFO [clojure-lsp.feature.clojuredocs:21] - [Clojuredocs] Refreshing clojuredocs cache...

ericdallo18:09:09

Server requests clojuredocs after startup and bring a edn with all cljdocs info, usually this takes a few secs only and we have a retry mechanism but almost is never triggered, only for low networks

ericdallo18:09:21

yeah, it should have another log after that

eccentric J18:09:45

2022-09-27T18:00:23.294Z  INFO [clojure-lsp.feature.clojuredocs:23] - [Clojuredocs] Refreshing clojuredocs cache took 714ms.
is the only other one that mentions clojuredocs that I see

ericdallo18:09:22

yep, so it's correct

ericdallo18:09:34

next hovers should bring cljdocs :thinking_face:

ericdallo18:09:42

oh, maybe is something with cljs?

ericdallo18:09:55

is there clojuredocs for cljs? šŸ˜…

eccentric J18:09:28

I guess I expected it to use clojuredocs still. I'll try a clojure project

ericdallo18:09:37

I think that's the issue, clojuredocs exists only for clojure.core :(

ericdallo18:09:14

There is nothing about cljs on https://clojuredocs.org/

ericdallo18:09:26

maybe they should add? sounds like a good issue

eccentric J18:09:02

Wouldn't it be the same content?

ericdallo18:09:36

pretty similar, but yet not the same code

ericdallo18:09:43

IMO clojuredocs should support it

eccentric J18:09:35

Ah yeah just found that too

ericdallo18:09:46

not that related though

ericdallo18:09:00

it seems no one asked that before šŸ˜…

eccentric J18:09:24

Seems that way, I'll give it a shot. Thanks for the help! Was throwing me off for a while there šŸ˜›

ericdallo18:09:43

You're welcome, LMK if need any more help!

eccentric J18:09:54

Confirming that was the issue

šŸ‘ 1