Skip to content

Commit 7e68df2

Browse files
authored
Add sensible category overrides for cider (#3504)
This possibility was enabled by #3226 It can be seen in use in SystemCrafters/crafted-emacs#241 or https://clojurians.slack.com/archives/C0617A8PQ/p1696684010392119?thread_ts=1696618691.247989&cid=C0617A8PQ| It provides a better default experience for those using orderless or other newer styles.
1 parent 604ffac commit 7e68df2

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848

4949
### Changes
5050

51+
- Ensure that `cider` completion isn't used with completion styles that are currently unsupported (`flex` `initials` `partial-completion`, `orderless`, etc).
52+
- This restores completions for users that favor those styles - otherwise the would see bad or no completions.
5153
- Improve support for multiple forms in the same line by replacing `beginning-of-defun` fn.
5254
- [#3390](https://github.com/clojure-emacs/cider/issues/3390): Enhance `cider-connect` to show all nREPLs available ports, instead of only Leiningen ones.
5355
- [#3408](https://github.com/clojure-emacs/cider/issues/3408): `cider-connect`: check `.nrepl-port`-like files for liveness, hiding them if they don't reflect an active port.

cider-completion.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ in the buffer."
249249
cider-company-unfiltered-candidates
250250
"CIDER backend-driven completion style."))
251251

252+
;; Currently CIDER completions only work for `basic`, and not `initials`, `partial-completion`, `orderless`, etc.
253+
;; So we ensure that those other styles aren't used with CIDER, otherwise one would see bad or no completions at all.
254+
;; This `add-to-list` call can be removed once we implement the other completion styles.
255+
(add-to-list 'completion-category-overrides '(cider (styles basic flex)))
256+
252257
(defun cider-company-enable-fuzzy-completion ()
253258
"Enable backend-driven fuzzy completion in the current buffer."
254259
(setq-local completion-styles '(cider)))

doc/modules/ROOT/pages/usage/code_completion.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ Normally kbd:[TAB] only indents, but now it will also do completion if the code
3535
is already properly indented.
3636
====
3737

38+
== Completion styles
39+
40+
CIDER defines (via the `completion-styles-alist` Elisp variable) a completion category named `cider`.
41+
42+
The `cider` completion category currently only supports `basic` and `flex` completion styles (and not `partial-completion`, `orderless`, etc).
43+
44+
CIDER declares so in this fashion:
45+
46+
[source,lisp]
47+
----
48+
(add-to-list 'completion-category-overrides '(cider (styles basic flex)))
49+
---
50+
51+
Note that `flex` will only work if you also enabled xref:usage/code_completion.adoc#fuzzy-candidate-matching[fuzzy candidate matching].
52+
3853
== Auto-completion
3954
4055
While the standard Emacs tooling works just fine, we suggest that

0 commit comments

Comments
 (0)