Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Add new customization variable `cider-font-lock-reader-conditionals` which toggles syntax highlighting of reader conditional expressions based on the buffer connection.
* Add new face `cider-reader-conditional-face` which is used to mark unused reader conditional expressions.
* [#1544](https://github.com/clojure-emacs/cider/issues/1544): Add a new defcustom `nrepl-use-ssh-fallback-for-remote-hosts` to control the behavior of `nrepl-connect` (and in turn that of `cider-connect`) for remote hosts.
* [#1910](https://github.com/clojure-emacs/cider/issues/1910): Add custom company-mode completion style to show fuzzy completions from Compliment.

### Changes

Expand Down
16 changes: 16 additions & 0 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,22 @@ in the buffer."
(cider-eldoc-thing-type eldoc-info))
(cider-eldoc-format-arglist arglists 0)))))

;; Fuzzy completion for company-mode

(defun cider-company-unfiltered-candidates (string table predicate point)
"Return CIDER completion candidates as is, without filtering them by prefix."
(cider-complete string))

(add-to-list 'completion-styles-alist
'(cider
cider-company-unfiltered-candidates
cider-company-unfiltered-candidates
"CIDER backend-driven completion style."))

(defun cider-company-enable-fuzzy-completion ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a matching disable command I guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be put on a hook and enables itself per-buffer. Does it still warrant a disable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's not a big deal but I can imagine some peoople will use this without a hook and it's generally a good idea to have a way to undo the effect of enabling this.

"Enable backend-driven fuzzy completion in the current buffer."
(setq-local completion-styles '(cider)))

(defun cider-stdin-handler (&optional buffer)
"Make a stdin response handler for BUFFER."
(nrepl-make-response-handler (or buffer (current-buffer))
Expand Down
16 changes: 11 additions & 5 deletions doc/code_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ the time of this writing it's still in development).
By default `company-mode` will provide completion candidates with the assumption
that whatever you've typed so far (e.g. `map-`) is a completion prefix (meaning
you'd get only candidates that have `map-` in the beginnings of their names).
You can get enhanced fuzzy completion with the CIDER-specific completion style
by adding:

You can get enhanced fuzzy completion with `company-mode` if you install the
additional package [company-flx](https://github.com/PythonNut/company-flx).
This is powered internally by [flx](https://github.com/lewang/flx).
```el
(add-hook 'cider-repl-mode-hook #'cider-company-enable-fuzzy-completion)
(add-hook 'cider-mode-hook #'cider-company-enable-fuzzy-completion)
```

Basically with `company-flx` enabled typing something like `mp` will show you
`map-indexed` as one of the possible completion candidates.
Now `company-mode` will accept certain fuzziness when matching candidates
against the prefix. For example, typing `mp` will show you `map-indexed` as one
of the possible completion candidates, `cji` will complete to `clojure.java.io`,
etc. Different completion examples are
listed [here](https://github.com/alexander-yakushev/compliment/wiki/Examples).

### Completion annotations

Expand Down