aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md5
-rw-r--r--README.md2
-rw-r--r--doc/modules/ROOT/pages/configuration.adoc17
-rw-r--r--doc/modules/ROOT/pages/index.adoc2
-rw-r--r--projectile.el68
5 files changed, 57 insertions, 37 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03b27ae..3348815 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,14 +5,15 @@
### New features
* New functions `projectile-acquire-root` and `projectile-process-current-project-buffers-current`
-* New project commands `projectile-package-project`, `projectile-install-project`.
+* New project commands `projectile-package-project`, `projectile-install-project`.
* [#1539](https://github.com/bbatsov/projectile/pull/1539): New defcustom `projectile-auto-discover` controlling whether to automatically discover projects in the search path when `projectile-mode` activates.
* Add [emacs-eldev](https://github.com/doublep/eldev) project type.
* Add Dart project type.
-* [#1555](https://github.com/bbatsov/projectile/pull/1555) Add search with ripgrep.
+* [#1555](https://github.com/bbatsov/projectile/pull/1555) Add search with ripgrep.
* Add Python-poetry project type.
* [#1576](https://github.com/bbatsov/projectile/pull/1576) Add OCaml [Dune](https://github.com/ocaml/dune) project type.
* Add [Mill](http://www.lihaoyi.com/mill/) project type.
+* Auto-detect completion system, supporting `ido`, `ivy`, `helm` and the default completion system.
### Changes
diff --git a/README.md b/README.md
index 5cb2dba..3ab6d93 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ it. Some of Projectile's features:
* run make in a project with a single key chord
* check for dirty repositories
* toggle read-only mode for the entire project
-* support for multiple minibuffer completion/selection libraries (e.g. `ido`, `ivy` and `helm`)
+* support for multiple minibuffer completion/selection libraries (`ido`, `ivy`, `helm` and the default completion system)
## Projectile in Action
diff --git a/doc/modules/ROOT/pages/configuration.adoc b/doc/modules/ROOT/pages/configuration.adoc
index 00edfe8..4abdaec 100644
--- a/doc/modules/ROOT/pages/configuration.adoc
+++ b/doc/modules/ROOT/pages/configuration.adoc
@@ -287,10 +287,20 @@ top-level directory.
== Completion Options
+=== Auto (default)
+
+By default Projectile detects the completion system in use, based
+on the mode variables `ido-mode`, `ivy-mode` and `helm-mode`.
+If none of those is activated, the `default` completion system is used.
+
=== Ido
-By default Projectile uses `ido` as its completion system. `ido` is
-extremely popular and it is built into Emacs.
+The `ido` completion system is extremely popular and it is built into Emacs.
+
+[source,elisp]
+----
+(setq projectile-completion-system 'ido)
+----
TIP: As already noted above if you're going to use the `ido` completion it's
**extremely highly** recommended that you install the optional
@@ -316,6 +326,9 @@ If you don't like `ido` and `ivy` you can use regular completion:
----
You might want to combine default completion with `icomplete-mode` for optimum results.
+Emacs 27 added `fido-mode` to `icomplete`. If you are using `fido-mode`, projectile will
+use the `default` completion system. The same holds for `selectrum` which also relies
+on the `default` completion system.
=== Custom Completion Function
diff --git a/doc/modules/ROOT/pages/index.adoc b/doc/modules/ROOT/pages/index.adoc
index 8227a5a..da23e8e 100644
--- a/doc/modules/ROOT/pages/index.adoc
+++ b/doc/modules/ROOT/pages/index.adoc
@@ -47,7 +47,7 @@ Projectile's features:
* visit project in dired
* run make in a project with a single key chord
* browse dirty version controlled projects
-* support for multiple minibuffer completion/selection libraries (e.g. `ido`, `ivy` and `helm`)
+* support for multiple minibuffer completion/selection libraries (`ido`, `ivy`, `helm` and the default completion system)
== Projectile in Action
diff --git a/projectile.el b/projectile.el
index 1b7fdbb..5320407 100644
--- a/projectile.el
+++ b/projectile.el
@@ -47,6 +47,9 @@
(require 'subr-x))
(eval-when-compile
+ (defvar ido-mode)
+ (defvar ivy-mode)
+ (defvar helm-mode)
(defvar ag-ignore-list)
(defvar ggtags-completion-table)
(defvar tags-completion-table)
@@ -199,10 +202,11 @@ When nil Projectile will consider the current directory the project root."
(const :tag "Yes" t)
(const :tag "Prompt for project" prompt)))
-(defcustom projectile-completion-system 'ido
+(defcustom projectile-completion-system 'auto
"The completion system to be used by Projectile."
:group 'projectile
:type '(radio
+ (const :tag "Auto-detect" auto)
(const :tag "Ido" ido)
(const :tag "Helm" helm)
(const :tag "Ivy" ivy)
@@ -1817,36 +1821,38 @@ project-root for every file."
(let ((prompt (projectile-prepend-project-name prompt))
res)
(setq res
- (cond
- ((eq projectile-completion-system 'ido)
- (ido-completing-read prompt choices nil nil initial-input))
- ((eq projectile-completion-system 'default)
- (completing-read prompt choices nil nil initial-input))
- ((eq projectile-completion-system 'helm)
- (if (and (fboundp 'helm)
- (fboundp 'helm-make-source))
- (helm :sources
- (helm-make-source "Projectile" 'helm-source-sync
- :candidates choices
- :action (if action
- (prog1 action
- (setq action nil))
- #'identity))
- :prompt prompt
- :input initial-input
- :buffer "*helm-projectile*")
- (user-error "Please install helm from \
-https://github.com/emacs-helm/helm")))
- ((eq projectile-completion-system 'ivy)
- (if (fboundp 'ivy-read)
- (ivy-read prompt choices
- :initial-input initial-input
- :action (prog1 action
- (setq action nil))
- :caller 'projectile-completing-read)
- (user-error "Please install ivy from \
-https://github.com/abo-abo/swiper")))
- (t (funcall projectile-completion-system prompt choices))))
+ (pcase (if (eq projectile-completion-system 'auto)
+ (cond
+ ((and (boundp 'ido-mode) ido-mode) 'ido)
+ ((and (boundp 'helm-mode) helm-mode) 'helm)
+ ((and (boundp 'ivy-mode) ivy-mode) 'ivy)
+ (t 'default))
+ projectile-completion-system)
+ ('default (completing-read prompt choices nil nil initial-input))
+ ('ido (ido-completing-read prompt choices nil nil initial-input))
+ ('helm
+ (if (and (fboundp 'helm)
+ (fboundp 'helm-make-source))
+ (helm :sources
+ (helm-make-source "Projectile" 'helm-source-sync
+ :candidates choices
+ :action (if action
+ (prog1 action
+ (setq action nil))
+ #'identity))
+ :prompt prompt
+ :input initial-input
+ :buffer "*helm-projectile*")
+ (user-error "Please install helm from melpa")))
+ ('ivy
+ (if (fboundp 'ivy-read)
+ (ivy-read prompt choices
+ :initial-input initial-input
+ :action (prog1 action
+ (setq action nil))
+ :caller 'projectile-completing-read)
+ (user-error "Please install ivy from elpa")))
+ (_ (funcall projectile-completion-system prompt choices))))
(if action
(funcall action res)
res)))