clojure-emacs/cljs-tooling

Add spec registry candidates

arichiardi opened this issue · 11 comments

Like in lumo for a start: https://github.com/anmonteiro/lumo/blob/master/src/cljs/snapshot/lumo/repl.cljs#L1240

If I remember correctly there was a problem with that implementation, still a good start.

Yeah, that'd be cool. @alexander-yakushev Is there some special support for specs in compliment?

Nothing yet, however, it is a good idea to add something for Spec. This will also require some long-due Compliment refactoring. I will think about it.

Any new development on this one, I would be in favor of following @alexander-yakushev guidance on this, the code above works in lumo but the keyword match there is based on regex and sometimes faulty. cljs-tooling does a better job.

Sorry, could you give me some more context again? Are we discussing adding Spec support to Compliment, or to cljs-tooling? If it's the latter, I'm not much of an input here:).

If it's the former, I wonder which support exactly you are looking for. Compliment already completes keywords, that works for specs too, however doesn't say it's a spec. Is this what you meant?

If it's the former, I wonder which support exactly you are looking for. Compliment already completes keywords, that works for specs too, however doesn't say it's a spec. Is this what you meant?

I guess that is the first step towards that, and if you do it I will follow the same approach so that it is uniform and implement it in cljs-tooling

Got you. So, what particularly do you have in mind beyond trivial keyword completion?

didn't think this through too much but for starters if the keyword is a spec, we could fetch the definition and show it in eldoc.

That's not something Compliment can currently do (the eldoc part). It can only offer completion candidates, and also provide documentation for each candidate (but I don't think CIDER uses the documentation part anymore). I could perhaps add this possibility if it's easier for CIDER to get it from Compliment. @bbatsov ?

Yep the eldoc would be another thing we would do from cider but we need to know from Compliment that a keyword is a spec and if Compliment has some info from the spec registry that could go in the company description/metadata

Another very useful idea would be to get the whole spec tree given one - aka recurse the spec tree with something like:

(defn nested-specs
  [spec]
  (reduce-all-specs (s/form spec)))

That's not something Compliment can currently do (the eldoc part). It can only offer completion candidates, and also provide documentation for each candidate (but I don't think CIDER uses the documentation part anymore). I could perhaps add this possibility if it's easier for CIDER to get it from Compliment. @bbatsov ?

Yeah, CIDER doesn't use it. It used it a while ago, but then we've implemented a more flexible eldoc in cider-nrepl. Part of the reason for this what that we needed a consistent approach to handle eldoc in Clojure and ClojureScript.