lsp

anthony-galea 2025-06-18T11:01:40.532599Z

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
pez 2025-06-20T14:48:35.282819Z

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.

ericdallo 2025-06-20T15:20:35.951089Z

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)

anthony-galea 2025-06-20T16:51:44.289269Z

@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 🙂

ericdallo 2025-06-20T17:19:29.749399Z

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

ericdallo 2025-06-18T15:50:07.358899Z

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

ericdallo 2025-06-18T15:50:18.795059Z

do you have any examples?

anthony-galea 2025-06-19T07:28:57.791639Z

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

anthony-galea 2025-06-19T07:39:47.861099Z

Another example: https://developers.redhat.com/blog/2020/11/25/how-to-configure-yaml-schema-to-make-editing-files-easier# but replace yaml with edn and schema with clj specs