lsp

frankitox 2025-09-30T20:56:02.842289Z

Hello 👋 I'm using custom linters in my project. And the code for the linters lives there too. Is it possible to extract that into a library, so that I can use it in other projects? Any public repo that I can peek at for 'inspiration'?

2025-09-30T21:28:20.975129Z

here's a very basic example from a library i wrote: https://github.com/NoahTheDuke/cond-plus/tree/master/resources/clj-kondo.exports/io.github.noahtheduke/cond_plus

frankitox 2025-09-30T21:32:50.130809Z

nice! thank you 🙏

borkdude 2025-09-30T21:33:33.728739Z

I think @franquito might be referring to the new LSP custom linters?

frankitox 2025-09-30T21:34:02.468209Z

Yep, but the idea is more or less the same, I guess?

borkdude 2025-09-30T21:34:29.552779Z

I'm sure the idea was inspired by what clj-kondo does, but they are not the same

borkdude 2025-09-30T21:35:06.273949Z

https://clojure-lsp.io/settings/#custom-linters

2025-09-30T21:35:13.162999Z

oh crap, i didn't know lsp supported custom linters, my apologies

borkdude 2025-09-30T21:35:46.393359Z

the file just has to be on the classpath: clojure-lsp.exports/linters/my_org/my_linter.clj

borkdude 2025-09-30T21:36:03.602959Z

so it doesn't matter if it's in a library or in your local project

borkdude 2025-09-30T21:36:35.619289Z

so the answer to your original question is: yes

frankitox 2025-09-30T21:37:53.201149Z

right! I'm not familiar with writing libraries so I'll be checking Noah's code. thanks both of you!

borkdude 2025-09-30T21:38:14.755219Z

Noah's code is about clj-kondo hooks, not about lsp custom linters

👍 1
borkdude 2025-09-30T21:39:07.531419Z

Just make a directory with a deps.edn. Add your file in src/clojure-lsp.exports/linters/my_org/my_linter.clj . Add it to github. You have a library you can reference as {:deps {io.github.your-account/my-library {:git/sha "..."}}}

❤️ 1
borkdude 2025-09-30T21:40:44.429229Z

you don't even have to add it to github. you can also reference it with {:deps {io.github.your-account/my-library {:local/root "../my-project"}}}

frankitox 2025-09-30T21:41:14.327069Z

Yep 🤔 I'll go that way, since I'm still tweaking the code

👍 1
borkdude 2025-09-30T21:42:06.116509Z

you might have to restart clojure-lsp before it finds this stuff

ericdallo 2025-09-30T21:46:04.490299Z

Answering the original question, yes, and we do that for nubank, having a common lein library that has all clojure-lsp custom linters + kondo hooks (called codestyle), so you could do the same. The lib must just be avaialble on classpath, usually in dev alias for clojure-lsp be able to use it

imre 2025-09-30T22:35:22.810479Z

The custom linters page linked above references clj-depend which I navigated to and saw the following. Wth.

ericdallo 2025-09-30T22:44:57.887539Z

That's weird, @contato794 is the maintainer, maybe he knows

ericdallo 2025-09-30T23:49:24.135509Z

Just talked with @contato794 and fixed docs, the correct is https://github.com/fabiodomingues/clj-depend

👍 1
ericdallo 2025-09-30T21:47:37.183149Z

Just thought about a clojure-lsp doctor command which outputs the classpath used for analysis and any other relevant info which might help a lot debugging multiple issues 🤔

👍 8
2