lsp 2025-06-18

o/ is there any prior art/thoughts around “spec-aware completion”? i.e. given a clojure spec and some data my text editor should be able to suggest valid keywords

👍 1
👍🏻 1

I think @ikitommi had a similar idea around type inference. Not exactly the same, but similar infrastructure. Remember this @ikitommi ? Mallireika, I think you labeled it.

I see now @anthony-galea, about the completion, this should work in clojure-lsp, there is probably a bug if completion is not working since it's just keyword completion, not related with spec right? about the type check, this is trick and harder, would need more thoughts on how to achieve that, not even sure where exactly this should live (clj-kondo, clojure-lsp, other tool etc)

@ericdallo yes, I initially said “spec-aware completion”, but a better name for what I have in mind is “spec-aware discovery and validation”. Completion is useful but I think the pain point I’m seeing is “discovery” and subsequent indication of what’s invalid. The specs for these deeply nested maps live in a separate repository and most users aren’t even aware of them, they just see the error messages after a tool processes their map (edn file), and it can take a while to figure out what’s wrong as the size of the map grows. As to “how” one alternative suggested by @mpenet was to use an annotation that tooling could then use for suggestions and validation. I intentionally used “tooling” because I’m also not sure where is the best place 🙂

Yes, makes sense, so the problem is more related to type checking, which is something that static analysis for Clojure lacks as it's hard to infer which type is which, @borkdude added basic type checking in clj-kondo so maybe he can give his advise too

hum, not really, kinda complex to support given many spec-aware libs but possible

do you have any examples?

@ericdallo I tried to come up with a better description of what I have in mind: https://gist.github.com/anthonygalea/5e4e7a9f4cf2a220c9858f470e454f9b