diff options
Diffstat (limited to '.emacs.d/lisp/init-completion.el')
-rw-r--r-- | .emacs.d/lisp/init-completion.el | 29 |
1 files changed, 29 insertions, 0 deletions
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) |