[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kind-icon f9d803cc12: Right-pad 2 char badges in termin
From: |
ELPA Syncer |
Subject: |
[elpa] externals/kind-icon f9d803cc12: Right-pad 2 char badges in terminal |
Date: |
Sat, 7 May 2022 18:57:36 -0400 (EDT) |
branch: externals/kind-icon
commit f9d803cc12a9406e7d7981f7ab3c065576055202
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Right-pad 2 char badges in terminal
---
kind-icon.el | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/kind-icon.el b/kind-icon.el
index f1f4edb137..c8f7a15ba2 100644
--- a/kind-icon.el
+++ b/kind-icon.el
@@ -255,6 +255,7 @@ background-color."
kind-face-bg
default-bg)))
(dfw (default-font-width))
+ (terminal (eq dfw 1))
(half (/ dfw 2))
(pad-right (propertize " " 'display `(space :width (,half))))
(pad-left (propertize " " 'display `(space :width (,(- dfw
half)))))
@@ -269,9 +270,11 @@ background-color."
(let* ((txt (truncate-string-to-width (cadr map) 2))
(len (length txt))
(txt-disp (if (eq len 2)
- (concat pad-left
- (propertize "_" 'display
txt)
- pad-right)
+ (if terminal
+ (concat txt " ")
+ (concat pad-left
+ (propertize "_"
'display txt)
+ pad-right))
(concat " " txt " "))))
(propertize txt-disp 'face
`(:weight bold :foreground ,col
:background ,bg-col))))))
@@ -315,25 +318,25 @@ and its result used as the affixation suffix, first
setting the
;;;###autoload
(defun kind-icon-enhance-completion (completion-function)
- "A wrapper for completion-in-region-functions.
+ "A wrapper for completion-in-region-functions.
This wrapper sets a custom affixation-function which places an
icon in the prefix slot. Use it like:
(setq completion-in-region-function
(kind-icon-enhance-completion
completion-in-region-function))"
- (lambda (start end table &optional pred)
- (let* ((str (buffer-substring start (point)))
- (metadata (completion-metadata str table pred))
- (kind-func (kind-icon--metadata-get metadata "company-kind"))
- (ann-func (kind-icon--metadata-get metadata "annotation-function"))
- (aff-func (kind-icon--metadata-get metadata
"affixation-function")))
- (when (and kind-func (not aff-func)) ;; add a custom affixation function
- (kind-icon-reset-cache)
- (setq completion-extra-properties
- (plist-put completion-extra-properties :affixation-function
- (kind-icon--affixation-function kind-func
ann-func)))))
- (funcall completion-function start end table pred)))
+ (lambda (start end table &optional pred)
+ (let* ((str (buffer-substring start (point)))
+ (metadata (completion-metadata str table pred))
+ (kind-func (kind-icon--metadata-get metadata "company-kind"))
+ (ann-func (kind-icon--metadata-get metadata "annotation-function"))
+ (aff-func (kind-icon--metadata-get metadata "affixation-function")))
+ (when (and kind-func (not aff-func)) ;; add a custom affixation function
+ (kind-icon-reset-cache)
+ (setq completion-extra-properties
+ (plist-put completion-extra-properties :affixation-function
+ (kind-icon--affixation-function kind-func ann-func)))))
+ (funcall completion-function start end table pred)))
(provide 'kind-icon)
;;; kind-icon.el ends here.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/kind-icon f9d803cc12: Right-pad 2 char badges in terminal,
ELPA Syncer <=