diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2021-11-08 12:17:03 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2021-11-08 12:17:03 +0100 |
| commit | f809dd6b3b13c5f60ef6eeb6db5e73d1aaf36dca (patch) | |
| tree | ad513f8e72b10c39d8a587e57c03d64628da4b1b | |
| parent | 69407ed50dc51ab6d64a885ffca510ea92da4012 (diff) | |
Add company-deprecated supportcompany-deprecated
| -rw-r--r-- | corfu.el | 49 |
1 files changed, 31 insertions, 18 deletions
@@ -120,6 +120,10 @@ completion began less than that number of seconds ago." :group 'corfu :group 'faces) +(defface corfu-deprecated + '((t :strike-through t)) + "Face used for deprecated candidates.") + (defface corfu-background '((((class color) (min-colors 88) (background dark)) :background "#191a1b") (((class color) (min-colors 88) (background light)) :background "#f0f0f0") @@ -559,24 +563,33 @@ completion began less than that number of seconds ago." (interactive) (completion-in-region-mode -1)) -(defun corfu--affixate (candidates) - "Annotate CANDIDATES with annotation function." - (if-let (aff (or (corfu--metadata-get corfu--metadata 'affixation-function) - (plist-get corfu--extra :affixation-function))) - (funcall aff candidates) - (if-let (ann (or (corfu--metadata-get corfu--metadata 'annotation-function) - (plist-get corfu--extra :annotation-function))) - (mapcar (lambda (cand) - (let ((suffix (or (funcall ann cand) ""))) - (list cand "" - ;; The default completion UI adds the `completions-annotations' face - ;; if no other faces are present. We use a custom `corfu-annotations' - ;; face to allow further styling which fits better for popups. - (if (text-property-not-all 0 (length suffix) 'face nil suffix) - suffix - (propertize suffix 'face 'corfu-annotations))))) - candidates) - (mapcar (lambda (cand) (list cand "" "")) candidates)))) +(defun corfu--affixate (cands) + "Annotate CANDS with annotation function." + (setq cands + (if-let (aff (or (corfu--metadata-get corfu--metadata 'affixation-function) + (plist-get corfu--extra :affixation-function))) + (funcall aff cands) + (if-let (ann (or (corfu--metadata-get corfu--metadata 'annotation-function) + (plist-get corfu--extra :annotation-function))) + (mapcar (lambda (cand) + (let ((suffix (or (funcall ann cand) ""))) + (list cand "" + ;; The default completion UI adds the `completions-annotations' face + ;; if no other faces are present. We use a custom `corfu-annotations' + ;; face to allow further styling which fits better for popups. + (if (text-property-not-all 0 (length suffix) 'face nil suffix) + suffix + (propertize suffix 'face 'corfu-annotations))))) + cands) + (mapcar (lambda (cand) (list cand "" "")) cands)))) + (if-let (dep (plist-get corfu--extra :company-deprecated)) + (mapcar (pcase-lambda (`(,cand ,prefix ,suffix)) + (when (funcall dep cand) + (setq cand (substring cand)) + (add-face-text-property 0 (length cand) 'corfu-deprecated 'append cand)) + (list cand prefix suffix)) + cands) + cands)) ;; XXX Do not use `completion-metadata-get' in order to avoid Marginalia. ;; The Marginalia annotators are way to heavy for the Corfu popup! |
