about summary refs log tree commit diff stats
path: root/.emacs.d
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2021-08-27 14:09:23 +0100
committerDavid Morgan <djm_uk@protonmail.com>2021-08-27 14:09:23 +0100
commit43075251e1a6eae37ec5811e8f45fb565f115390 (patch)
tree598f79d215e415815252461ab00b37c2689eb13b /.emacs.d
parent2e9a27187399d74103549b019ea87a8cf5b88729 (diff)
downloaddotfiles-43075251e1a6eae37ec5811e8f45fb565f115390.tar.gz
Wrap vertico-directory-enter to play nicely with Projectile
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/lisp/init-completion.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/.emacs.d/lisp/init-completion.el b/.emacs.d/lisp/init-completion.el
index 9baeefa..91f57f7 100644
--- a/.emacs.d/lisp/init-completion.el
+++ b/.emacs.d/lisp/init-completion.el
@@ -158,6 +158,19 @@
 ;; See init-packages.el for fetching of Vertico Extenions
 ;; Required extensions must be in the vertico-extensions var
 (use-package vertico-directory
+  :init
+  (defvar switching-project nil)
+  (defun vertico-directory-enter-or-switch-project ()
+    "Wrapper around vertico-directory-enter that plays nicely with Projectile."
+    (interactive)
+    (if switching-project
+        (vertico-exit)
+      (vertico-directory-enter)))
+  (defun read-project (orig &rest args)
+    (let ((switching-project t))
+      (apply orig args)))
+  (advice-add 'projectile-completing-read :around
+              'read-project)
   :config
   (defun vertico-directory-slash ()
     (interactive)
@@ -174,7 +187,7 @@
       (insert "~")))
   :load-path vertico-extensions-dir
   :bind (:map vertico-map
-              ;("RET" . vertico-directory-enter)
+              ("RET" . vertico-directory-enter-or-switch-project)
               ("/" . vertico-directory-slash)
               ("~" . vertico-directory-home)
               ("DEL" . vertico-directory-delete-char)