diff options
author | Alexander Yakushev <alex@bytopia.org> | 2017-02-21 12:27:15 +0200 |
---|---|---|
committer | Bozhidar Batsov <bozhidar.batsov@gmail.com> | 2017-03-07 15:36:57 +0200 |
commit | 34dca8a3ceca0e859d6e12d573ed84704d79aaa2 (patch) | |
tree | ad9c1fef1751512fea30fc5dd7c5f129c7d37d7e | |
parent | 52e69c102f2e6438196e223483a388115809bbc1 (diff) |
Add interactive function to flush Compliment caches
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | cider-client.el | 6 | ||||
-rw-r--r-- | cider-interaction.el | 9 | ||||
-rw-r--r-- | cider-mode.el | 4 | ||||
-rw-r--r-- | doc/code_completion.md | 8 |
5 files changed, 27 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d422433..afcd3f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * [#1910](https://github.com/clojure-emacs/cider/issues/1910): Add custom company-mode completion style to show fuzzy completions from Compliment. * Introduce `cider-*-global-options` for customizing options that are not related to tasks. * [#1731](https://github.com/clojure-emacs/cider/issues/1731): Change code in order to use the new `cider.tasks/add-middleware` boot tasks. +* [#1943](https://github.com/clojure-emacs/cider/pull/1943): Add interactive function to flush Compliment caches. ### Changes diff --git a/cider-client.el b/cider-client.el index 8d10ab93..9cd2fed0 100644 --- a/cider-client.el +++ b/cider-client.el @@ -911,6 +911,12 @@ CONTEXT represents a completion context for compliment." (cider-nrepl-send-sync-request nil 'abort-on-input)))) (nrepl-dict-get dict "completions"))) +(defun cider-sync-request:complete-flush-caches () + "Send \"complete-flush-caches\" op to flush Compliment's caches." + (cider-nrepl-send-sync-request (list "op" "complete-flush-caches" + "session" (cider-current-session)) + 'abort-on-input)) + (defun cider-sync-request:info (symbol &optional class member) "Send \"info\" op with parameters SYMBOL or CLASS and MEMBER." (let ((var-info (thread-first `("op" "info" diff --git a/cider-interaction.el b/cider-interaction.el index dc1ed068..d32ed5d8 100644 --- a/cider-interaction.el +++ b/cider-interaction.el @@ -573,6 +573,15 @@ The formatting is performed by `cider-annotate-completion-function'." :company-location #'cider-company-location :company-docsig #'cider-company-docsig)))) +(defun cider-completion-flush-caches () + "Force Compliment to refill its caches. + +This command should be used if Compliment fails to pick up new classnames +and methods from dependencies that were loaded dynamically after the REPL +has started." + (interactive) + (cider-sync-request:complete-flush-caches)) + (defun cider-company-location (var) "Open VAR's definition in a buffer. diff --git a/cider-mode.el b/cider-mode.el index 7bc0a98c..04b564d2 100644 --- a/cider-mode.el +++ b/cider-mode.el @@ -278,7 +278,9 @@ Configure `cider-cljs-*-repl' to change the ClojureScript REPL to use for your b ["Browse all namespaces" cider-browse-ns-all] ["Browse REPL input history" cider-repl-history] ["Browse classpath" cider-classpath] - ["Browse classpath entry" cider-open-classpath-entry])) + ["Browse classpath entry" cider-open-classpath-entry]) + ("Misc" + ["Flush completion cache" cider-completion-flush-caches])) "Menu for CIDER interactions.") (defconst cider-mode-map diff --git a/doc/code_completion.md b/doc/code_completion.md index e8496e1c..5973ea32 100644 --- a/doc/code_completion.md +++ b/doc/code_completion.md @@ -83,6 +83,14 @@ Completion annotations can be disabled by setting ![Completion Annotations](images/completion-annotations.png) +### Updating stale classes and methods cache + +Sometimes, the completion fails to recognize new classes that came with +dependencies that were loaded dynamically after the REPL has started (e.g. via +Boot). Executing `M-x cider-completion-flush-caches` (or going through the menu +`CIDER Interaction->Misc->Flush completion cache`) forces the completion backend +to re-read all classes it can find on the classpath. + ### Migrating from `auto-complete-mode` In case you have some `auto-complete-mode` configuration lying around and you |