Meta Redux: Modernizing CIDER’s Completion

Wait 5 sec.

CIDER’s code completion has quietly gotten quite good over the years, and Idon’t think it gets enough credit. It’s all built on Emacs’s standardcompletion-at-point, so it works with whatever completion UI you prefer -the built-in one, Corfu,company - without any special setup. Underthe hood compliment does theheavy lifting for Clojure (andclj-suitable forClojureScript), which means smart, backend-driven matching: mai completes tomap-indexed, cji to clojure.java.io, and an unimported BiFun tojava.util.function.BiFunction. The candidates come back ranked by the backendand are context-aware - it knows when you’re inside a -> or completing adeftype field.Lately I’ve been giving the Emacs side of things some attention, to bring it inline with the modern completion stack so many of us now use - Vertico, Corfu,Consult, Marginalia and friends. Two changes are worth calling out.The first is about the symbol prompts. A number of CIDER commands ask you for aClojure symbol when there’s nothing at point - cider-doc, cider-find-varand the like. Historically those prompts used the older completion machinery, soyour completing-read UI didn’t kick in and you were left with TAB and a*Completions* buffer. There’s now cider-use-completing-read-for-symbol (offby default for now); turn it on and those prompts go through completing-readover a collection that queries the running REPL lazily as you type. Vertico,Ivy, Helm - whatever you drive completing-read with - just works, and thecandidates carry their type and namespace.The second is smaller, but I like it a lot: annotations now line up in a propercolumn instead of trailing raggedly after each candidate.This comes from an affixation-function, the richer successor to the oldannotation-function, so every frontend that understands it - the built-in*Completions*, Corfu, Vertico - renders the aligned version. company keepsshowing its own trailing annotations, same as before.Both changes are in the latest CIDER MELPA build and will ship in the nextstable release. As always, I’d love to hear how they work out for you.That’s all I have for you today. Keep hacking!P.S. If you use Embark, I wrote up a fun way to act on Clojure symbols withit - documentation, jump-to-definition, inspect and so on - over onEmacs Redux.