lsp

a13 2025-08-06T08:50:05.500059Z

hi, a couple of issues with clojure-lsp • SOLVED is there a way to tell it not to touch my .clj-kondo/imports? • I already have :inline-def {:level :off} in .clj-kondo/config.edn but clojure-lsp ignores it and warns with Unused public var '[clojure-lsp/unused-public-var]

borkdude 2025-08-06T08:54:36.508349Z

yes: https://clojure-lsp.io/settings/ you can tell lsp to not copy configs

:copy-kondo-configs?

👍 1
borkdude 2025-08-06T08:54:46.575839Z

why would you ignore inline def tho...?

borkdude 2025-08-06T08:55:08.691559Z

it was the very first linter I ever wrote in clj-kondo :)

a13 2025-08-06T08:55:45.208729Z

the codebase I'm working on uses them for the capturing/debugging purposes extensively

borkdude 2025-08-06T08:57:15.782849Z

you could use something like https://github.com/borkdude/deflet to still have capturing/debugging, but no real vars in production. it also has a clj-kondo configuration.

a13 2025-08-06T09:03:42.187319Z

Yeah, thanks. I'm aware of that and other alternatives. It's just happened that def is already here, on fingertips and doesn't require any additional setup. Plus, we have a lot of repos to work on.

borkdude 2025-08-06T09:08:21.333439Z

There might be a performance penalty to this and also the chance that you're using same-named vars in different functions of the same namespace, causing concurrency trouble. But up to you of course.

a13 2025-08-06T09:08:52.800259Z

I know, that's why we use different names 🙂

borkdude 2025-08-06T09:09:52.479919Z

You could write a small macro called (def* ...) which elides the calls in production using some system variable or whatever. And then you could also write a clj-kondo hook for it that basically just does nothing

👍 1
borkdude 2025-08-06T09:10:36.932119Z

Anyway, the clojure-lsp bug is something to discuss with other people here

👍 1
a13 2025-08-06T09:33:27.918269Z

(partially) SOLVED by moving linters to .clj-kondo/config.edn ok, now I have these settings in my .lsp/config.edn

{:copy-kondo-configs? false
 :linters {:clojure-lsp/unused-public-var
           {:exclude-when-contains-meta #{:external?}}}}
but I'm still getting a message about unused public var for
(defn ^{:external? true} data-generator []

✅ 1
borkdude 2025-08-06T09:34:34.949519Z

have you tried:

(defn data-generator {:external? true} [])
?

borkdude 2025-08-06T09:34:46.726489Z

the first one should work too of course, but just checking

a13 2025-08-06T09:35:33.687599Z

yes, the same issue

borkdude 2025-08-06T09:36:17.271779Z

perhaps move this configuration to .clj-kondo/config.edn

borkdude 2025-08-06T09:36:43.662019Z

I remember lsp supporting that too

a13 2025-08-06T09:40:06.274689Z

yes, thanks, that works. The only thing is I had to disconnect and connect to lsp again to see the changes, but probably it's the Emacs issue

borkdude 2025-08-06T09:40:53.425929Z

so maybe both work and that was the issue then

a13 2025-08-06T09:42:13.513549Z

no, it didn't work with :linters expressions in .lsp/config.edn

borkdude 2025-08-06T09:42:22.531519Z

k

a13 2025-08-06T09:44:02.088929Z

Anyway, I don't really care where the settings are as long as they work. Thank you again for your help!

👍 1