lsp

Evan 2024-12-02T14:41:03.792749Z

I have noticed that clojure-lsp diagnostics have been disappearing from certain files in neovim. I wasn't certain if the problem was with my neovim setup or clojure-lsp, but after a bit of investigation I have been able to reproduce the issue using the cli. clojure-lsp throws the following exception when interop calls are present in the analyzed namespace:

[ 99%] Project analyzed            Finding diagnostics...
Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: No matching clause: :on
	at java.base@21.0.5/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base@21.0.5/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at clojure.core$deref_future.invokeStatic(core.clj:2317)
	at clojure.core$future_call$reify__8574.deref(core.clj:7121)
	at clojure.core$deref.invokeStatic(core.clj:2337)
	at clojure.core$deref.invoke(core.clj:2323)
	at clojure.core$map$fn__5954.invoke(core.clj:2770)
	at clojure.lang.LazySeq.force(LazySeq.java:50)
	at clojure.lang.LazySeq.lockAndForce(LazySeq.java:60)
	at clojure.lang.LazySeq.sval(LazySeq.java:69)
	at clojure.lang.LazySeq.unwrap(LazySeq.java:77)
	at clojure.lang.LazySeq.realize(LazySeq.java:93)
	at clojure.lang.LazySeq.seq(LazySeq.java:106)
	at clojure.lang.RT.seq(RT.java:555)
	at clojure.core$seq__5486.invokeStatic(core.clj:139)
	at clojure.core$filter$fn__5981.invoke(core.clj:2826)
	at clojure.lang.LazySeq.force(LazySeq.java:50)
	at clojure.lang.LazySeq.realize(LazySeq.java:89)
	at clojure.lang.LazySeq.seq(LazySeq.java:106)
	at clojure.lang.RT.seq(RT.java:555)
	at clojure.core$seq__5486.invokeStatic(core.clj:139)
	at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
	at clojure.core.protocols$fn__8262.invokeStatic(protocols.clj:74)
	at clojure.core.protocols$fn__8262.invoke(protocols.clj:74)
	at clojure.core.protocols$fn__8203$G__8198__8216.invoke(protocols.clj:13)
	at clojure.core$reduce.invokeStatic(core.clj:6965)
	at clojure.core$reduce.invoke(core.clj:6947)
	at clojure_lsp.internal_api$diagnostics_STAR_.invokeStatic(internal_api.clj:346)
	at clojure_lsp.internal_api$diagnostics_STAR_.invoke(internal_api.clj:336)
	at clojure_lsp.internal_api$diagnostics.invokeStatic(internal_api.clj:484)
	at clojure_lsp.internal_api$diagnostics.invoke(internal_api.clj:483)
	at clojure_lsp.main$handle_action_BANG_.invokeStatic(main.clj:159)
	at clojure_lsp.main$handle_action_BANG_.invoke(main.clj:150)
	at clojure_lsp.main$run_BANG_.invokeStatic(main.clj:180)
	at clojure_lsp.main$run_BANG_.doInvoke(main.clj:173)
	at clojure.lang.RestFn.applyTo(RestFn.java:140)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$apply.invoke(core.clj:662)
	at clojure_lsp.main$main.invokeStatic(main.clj:183)
	at clojure_lsp.main$main.doInvoke(main.clj:182)
	at clojure.lang.RestFn.applyTo(RestFn.java:140)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$apply.invoke(core.clj:662)
	at clojure_lsp.main$_main.invokeStatic(main.clj:208)
	at clojure_lsp.main$_main.doInvoke(main.clj:206)
	at clojure.lang.RestFn.applyTo(RestFn.java:140)
	at clojure_lsp.main.main(Unknown Source)
	at java.base@21.0.5/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: java.lang.IllegalArgumentException: No matching clause: :on
	at clojure_lsp.feature.diagnostics$kondo_finding__GT_diagnostic.invokeStatic(diagnostics.clj:115)
	at clojure_lsp.feature.diagnostics$kondo_finding__GT_diagnostic.invoke(diagnostics.clj:92)
	at clojure_lsp.feature.diagnostics$kondo_findings__GT_diagnostics$fn__17899.invoke(diagnostics.clj:146)
	at clojure.core$mapv$fn__8565.invoke(core.clj:7059)
	at clojure.lang.ArrayChunk.reduce(ArrayChunk.java:65)
	at clojure.core.protocols$fn__8270.invokeStatic(protocols.clj:135)
	at clojure.core.protocols$fn__8270.invoke(protocols.clj:123)
	at clojure.core.protocols$fn__8229$G__8224__8238.invoke(protocols.clj:19)
	at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
	at clojure.core.protocols$fn__8262.invokeStatic(protocols.clj:74)
	at clojure.core.protocols$fn__8262.invoke(protocols.clj:74)
	at clojure.core.protocols$fn__8203$G__8198__8216.invoke(protocols.clj:13)
	at clojure.core$reduce.invokeStatic(core.clj:6965)
	at clojure.core$mapv.invokeStatic(core.clj:7050)
	at clojure.core$mapv.invoke(core.clj:7050)
	at clojure_lsp.feature.diagnostics$kondo_findings__GT_diagnostics.invokeStatic(diagnostics.clj:146)
	at clojure_lsp.feature.diagnostics$kondo_findings__GT_diagnostics.invoke(diagnostics.clj:137)
	at clojure_lsp.feature.diagnostics$find_diagnostics.invokeStatic(diagnostics.clj:184)
	at clojure_lsp.feature.diagnostics$find_diagnostics.invoke(diagnostics.clj:177)
	at clojure_lsp.internal_api$diagnostics_STAR_$fn__37752.invoke(internal_api.clj:344)
	at clojure.core$pmap$fn__8582$fn__8583.invoke(core.clj:7169)
	at clojure.core$binding_conveyor_fn$fn__5842.invoke(core.clj:2047)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.base@21.0.5/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base@21.0.5/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base@21.0.5/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base@21.0.5/java.lang.Thread.runWith(Thread.java:1596)
	at java.base@21.0.5/java.lang.Thread.run(Thread.java:1583)
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:896)
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:872)
This can be repoduced via the following:
mkdir -p lsp/src/missing
cat <<EOF >lsp/src/missing/diagnostics.clj
(ns missing.diagnostics
   (:require
    ;; unused-namespace
    [clojure.set :as set]))

(def obj
  (Object.))

(defn ok []
  (prn "hi"))

(defn ok2 []
  (throw (Exception. "dot")))

(defn ok3 []
  (str obj))

;; uncomment any of the following to break clojure-lsp

(defn broken []
  (.toString obj))

;; (defn broken2 []
;;   (.-something obj))

;; ClojureDart no-dot-required constructor
;; 
;; (throw (Exception "no dot"))
EOF

cd lsp
clojure-lsp diagnostics --filenames src/missing/diagnostics.clj

ericdallo 2024-12-02T14:42:03.911199Z

looks like a bug in clojure-lsp indeed

ericdallo 2024-12-02T14:42:31.316709Z

let me try that repro soon

👍 1
Evan 2025-09-17T13:55:49.383539Z

Any news on this?

ericdallo 2025-09-17T14:00:49.092219Z

@evan.green I think I lost that, sorry. I can't repro that on latest clojure-lsp:

ericdallo 2025-09-17T14:01:04.592539Z

Evan 2025-09-17T14:05:39.442959Z

I just tested it myself on the latest stable version. Did you un-comment one of the problematic defs before running?

ericdallo 2025-09-17T14:07:45.983899Z

Hum, yes

ericdallo 2025-09-17T14:09:13.028159Z

(ns missing.diagnostics
   (:require
    ;; unused-namespace
    [clojure.set :as set]))

(def obj
  (Object.))

(defn ok []
  (prn "hi"))

(defn ok2 []
  (throw (Exception. "dot")))

(defn ok3 []
  (str obj))

;; uncomment any of the following to break clojure-lsp

(defn broken []
  (.toString obj))

 (defn broken2 []
   (.-something obj))

;;  ClojureDart no-dot-required constructor
;; \#new-and--can-be-omitted
(throw (Exception "no dot"))

Evan 2025-09-17T14:12:01.424799Z

Ok. It looks like the issue is with Neovim then, as the diagnostics don't show there, but do on the command line.

ericdallo 2025-09-17T14:13:11.676129Z

weird too, I can't see why neovim would not show them if using lsp properly

Evan 2025-09-17T14:13:27.994699Z

Disabling clj-kondo in clojure-lsp and running it directly as a plugin make them show up again.

ericdallo 2025-09-17T14:14:15.565489Z

not sure I got what you did, you disabled clj-kondo in clojure-lsp via config?

Evan 2025-09-17T14:15:40.585869Z

Yes, and then as a work-around add it back via https://github.com/nvimtools/none-ls.nvim.

ericdallo 2025-09-17T14:34:05.436359Z

yeah, I don't know what else to check on clojure-lsp side, everything looks correct

Evan 2025-09-17T14:38:42.894209Z

Ok. Thanks for looking into it... Do you think it's worth asking about in #clj-kondo?

ericdallo 2025-09-17T14:40:38.139749Z

not sure, since clojure-lsp uses kondo and it's working, it's probably working in clj-kondo raw as well, it's something else I'd say, like a older version or so

👍 1