emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/company 7b74d24: Improve company-text-icons-mapping's u


From: ELPA Syncer
Subject: [elpa] externals/company 7b74d24: Improve company-text-icons-mapping's usability
Date: Sun, 2 May 2021 20:57:06 -0400 (EDT)

branch: externals/company
commit 7b74d2404e07ff1774d9f6b3b36483e0a33a7403
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Improve company-text-icons-mapping's usability
    
    * Reuse the kind->face mapping originally introduced for 
company-dot-icons-margin.
    * And rename it.
    * Use plain English chars for the icons, a few of them capital.
    * (Experimental) Add a space to the left of the char as well, and use bold.
    
    All of this brings it fairly close to how Atom's popup looks, which is 
probably a good thing.
    
    #1088
---
 company.el | 114 ++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 64 insertions(+), 50 deletions(-)

diff --git a/company.el b/company.el
index 2e2c49f..e1647ba 100644
--- a/company.el
+++ b/company.el
@@ -1479,54 +1479,37 @@ end of the match."
                                 selected))
 
 (defcustom company-text-icons-mapping
-  '((array . "Α")
-    (boolean . "β")
-    (class . "γ")
-    (color . "Δ")
-    (constant . "ε")
-    (enum-member . "ζ")
-    (enum . "Ζ")
-    (event . "η")
-    (field . "θ")
-    (file . "Ɩ")
-    (folder . "⍳")
-    (interface . "ϰ")
-    (keyword . "ν")
-    (method . "λ")
-    (function . "ƒ")
-    (module . "Ο")
-    (numeric . "π")
-    (operator . "⊙")
-    (parameter . "ρ")
-    (property . "σ")
-    (ruler . "τ")
-    (snippet . "υ")
-    (string . "φ")
-    (struct . "Χ")
-    (text . "μ")
-    (value . "Ζ")
-    (variable . "ѱ")
-    (t . "ξ"))
+  '((array . "a")
+    (boolean . "b")
+    (class . "c")
+    (color . "c")
+    (constant . "c")
+    (enum-member . "e")
+    (enum . "e")
+    (field . "f")
+    (file . "f")
+    (folder . "d")
+    (interface . "i")
+    (keyword . "k")
+    (method . "m")
+    (function . "f")
+    (module . "M")
+    (numeric . "n")
+    (operator . "o")
+    (parameter . "p")
+    (property . "p")
+    (ruler . "r")
+    (snippet . "S")
+    (string . "s")
+    (struct . "s")
+    (text . "t")
+    (value . "v")
+    (variable . "v")
+    (t . "."))
   "Mapping of the text icons."
   :type 'list)
 
-(defcustom company-text-icons-format "%s "
-  "Format string for printing the text icons."
-  :type 'string)
-
-(defun company-text-icons-margin (candidate _selected)
-  "Margin function which returns unicode icons."
-  (when-let ((candidate candidate)
-             (kind (company-call-backend 'kind candidate))
-             (icon (or (alist-get kind company-text-icons-mapping)
-                       (alist-get t company-text-icons-mapping))))
-    (format company-text-icons-format icon)))
-
-(defcustom company-dot-icons-format "●"
-  "Format string for `company-dot-icons-margin'."
-  :type 'string)
-
-(defcustom company-dot-icons-face-mapping
+(defcustom company-text-kind-face-mapping
   '((array . font-lock-type-face)
     (boolean . font-lock-builtin-face)
     (class . font-lock-type-face)
@@ -1546,25 +1529,56 @@ end of the match."
     (operator . font-lock-comment-delimiter-face)
     (parameter . font-lock-builtin-face)
     (property . font-lock-variable-name-face)
-    ; (ruler . nil)
+    ;; (ruler . nil)
     (snippet . font-lock-string-face)
     (string . font-lock-string-face)
     (struct . font-lock-variable-name-face)
-    ; (text . nil)
+    ;; (text . nil)
     (value . font-lock-builtin-face)
     (variable . font-lock-variable-name-face)
     (t . deemphasized))
-  "Faces mapping for `company-dot-icons-margin'."
+  "Faces mapping for `company-text-icons-margin' and 
`company-dot-icons-margin'."
   :type '(repeat
           (cons (symbol :tag "Kind name")
                 (face :tag "Face to use for it"))))
 
+(defcustom company-text-face-extra-attributes '(:weight bold)
+  "Additional attributes to add to text icons' faces.
+If non-nil, an anonymous face will be generated.
+Only affects `company-text-icons-margin'."
+  :type 'list)
+
+(defcustom company-text-icons-format " %s "
+  "Format string for printing the text icons."
+  :type 'string)
+
+(defun company-text-icons-margin (candidate _selected)
+  "Margin function which returns unicode icons."
+  (when-let ((candidate candidate)
+             (kind (company-call-backend 'kind candidate))
+             (icon (or (alist-get kind company-text-icons-mapping)
+                       (alist-get t company-text-icons-mapping)))
+             (face (or (assoc-default kind
+                                      company-text-kind-face-mapping)
+                       (assoc-default t company-text-kind-face-mapping))))
+    (propertize
+     (format company-text-icons-format icon)
+     'face
+     (if company-text-face-extra-attributes
+         (append company-text-face-extra-attributes
+                 (list :inherit face))
+       face))))
+
+(defcustom company-dot-icons-format "●"
+  "Format string for `company-dot-icons-margin'."
+  :type 'string)
+
 (defun company-dot-icons-margin (candidate _selected)
   "Margin function that uses a colored dot to display completion kind."
   (when-let ((kind (company-call-backend 'kind candidate))
              (face (or (assoc-default kind
-                                      company-dot-icons-face-mapping)
-                       (assoc-default t company-dot-icons-face-mapping))))
+                                      company-text-kind-face-mapping)
+                       (assoc-default t company-text-kind-face-mapping))))
     (propertize company-dot-icons-format 'face face)))
 
 (defun company-detect-icons-margin (candidate selected)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]