cljs-tooling icon indicating copy to clipboard operation
cljs-tooling copied to clipboard

Add spec registry candidates

Open arichiardi opened this issue 6 years ago • 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.

arichiardi avatar Jun 03 '18 03:06 arichiardi

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

bbatsov avatar Jun 03 '18 04:06 bbatsov

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.

alexander-yakushev avatar Jun 03 '18 05:06 alexander-yakushev

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.

arichiardi avatar Aug 09 '18 15:08 arichiardi

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?

alexander-yakushev avatar Aug 24 '18 19:08 alexander-yakushev

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

arichiardi avatar Aug 24 '18 20:08 arichiardi

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

alexander-yakushev avatar Aug 24 '18 20:08 alexander-yakushev

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.

arichiardi avatar Aug 24 '18 20:08 arichiardi

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 ?

alexander-yakushev avatar Aug 24 '18 20:08 alexander-yakushev

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

arichiardi avatar Aug 24 '18 21:08 arichiardi

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)))

arichiardi avatar Sep 17 '18 01:09 arichiardi

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.

bbatsov avatar Sep 17 '18 11:09 bbatsov