about summary refs log tree commit diff stats
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2022-10-17 16:05:08 +0100
committerDavid Morgan <djm_uk@protonmail.com>2022-10-17 16:05:08 +0100
commit6efcee4e88d3fe2548e5ad331e9d585485ff681e (patch)
tree93ef06b6687343a9b82812aff506f4c4cb192735 /.emacs.d/lisp
parent57288a4d9079dca6cc99b3d84413a839691d0964 (diff)
downloaddotfiles-6efcee4e88d3fe2548e5ad331e9d585485ff681e.tar.gz
Add some corfu extensions
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-completion.el36
-rw-r--r--.emacs.d/lisp/init-minibuffer.el9
2 files changed, 33 insertions, 12 deletions
diff --git a/.emacs.d/lisp/init-completion.el b/.emacs.d/lisp/init-completion.el
index dbc94e4..2c8d00d 100644
--- a/.emacs.d/lisp/init-completion.el
+++ b/.emacs.d/lisp/init-completion.el
@@ -130,16 +130,40 @@ no words in between, beginning with the first word."
 
 ;; code completion - corfu
 (use-package corfu
-  ;; Optional customizations
+  :straight (corfu :files (:defaults "extensions/*")
+                   :includes (corfu-indexed corfu-quick corfu-history corfu-info))
   :custom
-  (corfu-cycle t)            ;; Enable cycling for `corfu-next/previous'
+  (corfu-cycle t)
   :bind (:map corfu-map
-         ("TAB" . corfu-next)
-         ([tab] . corfu-next)
-         ("S-TAB" . corfu-previous)
-         ([backtab] . corfu-previous))
+              ("TAB" . corfu-next)
+              ([tab] . corfu-next)
+              ("S-TAB" . corfu-previous)
+              ([backtab] . corfu-previous))
   :hook (emacs-startup . global-corfu-mode))
 
+(defmacro use-extension (pkg name &rest args)
+  "Like `use-package', but for a package extension.
+`PKG' is the name of the package, `NAME' and `ARGS' are as with `use-package'"
+  (declare (indent defun))
+  `(use-package ,name
+     :straight nil
+     :after pkg
+     :demand t
+     ,@args))
+
+(use-extension corfu corfu-indexed
+  :config (corfu-indexed-mode 1))
+
+(use-extension corfu corfu-quick
+  :bind (:map corfu-map
+              ("C-;" . corfu-quick-insert)
+              ("C-'" . corfu-quick-exit)))
+
+(use-extension corfu corfu-history
+  :config
+  (corfu-history-mode 1)
+  (add-to-list 'savehist-additional-variables 'corfu-history))
+
 (use-package corfu-doc
   :hook
   (corfu-mode . corfu-doc-mode))
diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el
index 80f3603..3256dc1 100644
--- a/.emacs.d/lisp/init-minibuffer.el
+++ b/.emacs.d/lisp/init-minibuffer.el
@@ -42,6 +42,7 @@
                      (propertize "ยป " 'face 'vertico-current)
                    "  ")
                  cand)))
+
   (defun define-vertico-key (key &rest defs)
     "Define KEY conditionally in the vertico keymap.
 DEFS is a plist associating completion categories to commands."
@@ -147,14 +148,10 @@ DEFS is a plist associating completion categories to commands."
   :config
   (add-to-list 'savehist-additional-variables 'vertico-repeat-history))
 
-(use-feature vertico-indexed
-  :after vertico
-  :demand t
+(use-extension vertico vertico-indexed
   :config (vertico-indexed-mode 1))
 
-(use-feature vertico-quick
-  :after vertico
-  :demand t
+(use-extension vertico vertico-quick
   :bind (:map vertico-map
               ("C-;" . vertico-quick-insert)
               ("C-'" . vertico-quick-exit)))