diff options
author | Guangxiong Lin <[email protected]> | 2022-03-20 10:12:46 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2022-03-20 10:12:46 +0800 |
commit | 0e18684eef402794f470b5a10658002136cb5195 (patch) | |
tree | dee6adcf24015879e982e411802f396f16f6832c | |
parent | e4b65a6ea63c4043167c7ded7a8fe688d7780335 (diff) | |
download | dotfiles-0e18684eef402794f470b5a10658002136cb5195.tar.gz dotfiles-0e18684eef402794f470b5a10658002136cb5195.tar.bz2 dotfiles-0e18684eef402794f470b5a10658002136cb5195.zip |
Separate completion config (emacs)
-rw-r--r-- | .emacs.d/init.el | 1 | ||||
-rw-r--r-- | .emacs.d/lisp/init-completion.el | 29 | ||||
-rw-r--r-- | .emacs.d/lisp/init-corfu.el | 6 | ||||
-rw-r--r-- | .emacs.d/lisp/init-minibuffer.el | 23 |
4 files changed, 30 insertions, 29 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 8fad1fc..bd82916 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -20,6 +20,7 @@ (require 'init-package) (require 'init-utils) (require 'init-evil) +(require 'init-completion) (require 'init-minibuffer) (require 'init-company) (require 'init-corfu) diff --git a/.emacs.d/lisp/init-completion.el b/.emacs.d/lisp/init-completion.el new file mode 100644 index 0000000..fb2b2b0 --- /dev/null +++ b/.emacs.d/lisp/init-completion.el @@ -0,0 +1,29 @@ +(when (gx/maybe-require-package 'orderless) + + (setq orderless-matching-styles + '(orderless-literal orderless-regexp orderless-prefixes)) + + (defun gx/orderless-without-if-bang (pattern _index _total) + (cond + ((equal "!" pattern) + '(orderless-literal . "")) + ((string-prefix-p "!" pattern) + `(orderless-without-literal . ,(substring pattern 1))))) + + (defun gx/orderless-flex-if-twiddle (pattern _index _total) + (when (string-suffix-p "~" pattern) + `(orderless-flex . ,(substring pattern 0 -1)))) + + (setq orderless-style-dispatchers + '(gx/orderless-without-if-bang + gx/orderless-flex-if-twiddle)) + + (setq completion-styles '(substring orderless flex) + completion-category-defaults nil + completion-category-overrides + '((file (styles . (partial-completion)))))) + +(when (gx/maybe-require-package 'cape) + (add-to-list 'completion-at-point-functions #'cape-file)) + +(provide 'init-completion) diff --git a/.emacs.d/lisp/init-corfu.el b/.emacs.d/lisp/init-corfu.el index b72125c..ec88b8d 100644 --- a/.emacs.d/lisp/init-corfu.el +++ b/.emacs.d/lisp/init-corfu.el @@ -17,10 +17,4 @@ (define-key corfu-map (kbd "S-TAB") 'corfu-previous) (define-key corfu-map (kbd "<backtab>") 'corfu-previous)) -(when (gx/maybe-require-package 'orderless) - (setq completion-styles '(orderless) - completion-category-defaults nil - completion-category-overrides - '((file (styles . (partial-completion)))))) - (provide 'init-corfu) diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el index bf38675..6fa5061 100644 --- a/.emacs.d/lisp/init-minibuffer.el +++ b/.emacs.d/lisp/init-minibuffer.el @@ -18,29 +18,6 @@ (define-key vertico-map (kbd "C-u") (lambda () (interactive) (vertico-previous (/ vertico-count 2))))) -(when (gx/maybe-require-package 'orderless) - (setq orderless-matching-styles '(orderless-literal orderless-regexp orderless-flex)) - - (defun gx/orderless-without-if-bang (pattern _index _total) - (cond - ((equal "!" pattern) - '(orderless-literal . "")) - ((string-prefix-p "!" pattern) - `(orderless-without-literal . ,(substring pattern 1))))) - - (defun gx/orderless-flex-if-twiddle (pattern _index _total) - (when (string-suffix-p "~" pattern) - `(orderless-flex . ,(substring pattern 0 -1)))) - - (setq orderless-style-dispatchers '(gx/orderless-without-if-bang - gx/orderless-flex-if-twiddle)) - - (defun gx/setup-completion-in-minibuffer () - (setq-local completion-styles '(substring orderless) - completion-category-defaults nil - completion-category-overrides '((file (styles partial-completion))))) - (add-hook 'minibuffer-setup-hook #'gx/setup-completion-in-minibuffer)) - (when (gx/maybe-require-package 'consult) (with-eval-after-load 'evil (evil-define-key 'normal 'global |