[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/helm b34d725c3c 01/11: helm-imenu supports showing item ty
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/helm b34d725c3c 01/11: helm-imenu supports showing item types by icons |
Date: |
Tue, 31 May 2022 02:58:40 -0400 (EDT) |
branch: elpa/helm
commit b34d725c3c1831448f8277664092a51659b449af
Author: Ta Quang Trung <taquangtrungvn@gmail.com>
Commit: Ta Quang Trung <taquangtrungvn@gmail.com>
helm-imenu supports showing item types by icons
---
helm-imenu.el | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 128 insertions(+), 8 deletions(-)
diff --git a/helm-imenu.el b/helm-imenu.el
index 0844d6e28e..5a4a57a308 100644
--- a/helm-imenu.el
+++ b/helm-imenu.el
@@ -23,6 +23,7 @@
(require 'imenu)
(require 'helm-utils)
(require 'helm-help)
+(require 'company)
(declare-function which-function "which-func")
@@ -84,6 +85,12 @@ string."
"Extra modes where `helm-imenu-in-all-buffers' should look into."
:group 'helm-imenu
:type '(repeat symbol))
+
+(defcustom helm-imenu-show-icons t
+ "Display imenu item types by VSCode icons or text format."
+ :group 'helm-imenu
+ :type 'boolean)
+
;;; keymap
(defvar helm-imenu-map
@@ -143,6 +150,82 @@ string."
(make-variable-buffer-local 'helm-cached-imenu-tick)
(defvar helm-imenu--in-all-buffers-cache nil)
+
+(defvar helm-imenu-icons-mapping
+ '(("Array" . "symbol-array.svg")
+ ("Arrays" . "symbol-array.svg")
+ ("Boolean" . "symbol-boolean.svg")
+ ("Booleans" . "symbol-boolean.svg")
+ ("Class" . "symbol-class.svg")
+ ("Classes" . "symbol-class.svg")
+ ("Color" . "symbol-color.svg")
+ ("Colors" . "symbol-color.svg")
+ ("Constant" . "symbol-constant.svg")
+ ("Constants" . "symbol-constant.svg")
+ ("Constructor" . "symbol-method.svg")
+ ("Constructors" . "symbol-method.svg")
+ ("Enum Member" . "symbol-enumerator-member.svg")
+ ("Enum Members" . "symbol-enumerator-member.svg")
+ ("Enum" . "symbol-enumerator.svg")
+ ("Enums" . "symbol-enumerator.svg")
+ ("Event" . "symbol-event.svg")
+ ("Events" . "symbol-event.svg")
+ ("Field" . "symbol-field.svg")
+ ("Fields" . "symbol-field.svg")
+ ("File" . "symbol-file.svg")
+ ("Files" . "symbol-file.svg")
+ ("Folder" . "folder.svg")
+ ("Folders" . "folder.svg")
+ ("Interface" . "symbol-interface.svg")
+ ("Interfaces" . "symbol-interface.svg")
+ ("Keyword" . "symbol-keyword.svg")
+ ("Keywords" . "symbol-keyword.svg")
+ ("Method" . "symbol-method.svg")
+ ("Methods" . "symbol-method.svg")
+ ("Defun" . "symbol-method.svg")
+ ("Defuns" . "symbol-method.svg")
+ ("Fn" . "symbol-method.svg")
+ ("Fns" . "symbol-method.svg")
+ ("Function" . "symbol-method.svg")
+ ("Functions" . "symbol-method.svg")
+ ("Module" . "symbol-namespace.svg")
+ ("Modules" . "symbol-namespace.svg")
+ ("Misc" . "symbol-misc.svg")
+ ("Miscs" . "symbol-misc.svg")
+ ("Module" . "symbol-namespace.svg")
+ ("Modules" . "symbol-namespace.svg")
+ ("Numeric" . "symbol-numeric.svg")
+ ("Numerics" . "symbol-numeric.svg")
+ ("Object" . "symbol-namespace.svg")
+ ("Objects" . "symbol-namespace.svg")
+ ("Operator" . "symbol-operator.svg")
+ ("Operators" . "symbol-operator.svg")
+ ("Property" . "symbol-property.svg")
+ ("Propertys" . "symbol-property.svg")
+ ("Reference" . "references.svg")
+ ("References" . "references.svg")
+ ("Snippet" . "symbol-snippet.svg")
+ ("Snippets" . "symbol-snippet.svg")
+ ("String" . "symbol-string.svg")
+ ("Strings" . "symbol-string.svg")
+ ("Struct" . "symbol-structure.svg")
+ ("Structs" . "symbol-structure.svg")
+ ("Text" . "symbol-key.svg")
+ ("Texts" . "symbol-key.svg")
+ ("Type" . "symbol-enumerator.svg")
+ ("Types" . "symbol-enumerator.svg")
+ ("Type Parameter" . "symbol-parameter.svg")
+ ("Type Parameters" . "symbol-parameter.svg")
+ ("Unit" . "symbol-ruler.svg")
+ ("Units" . "symbol-ruler.svg")
+ ("Value" . "symbol-enumerator.svg")
+ ("Values" . "symbol-enumerator.svg")
+ ("Variable" . "symbol-variable.svg")
+ ("Variables" . "symbol-variable.svg")
+ ("Misc" . "symbol-misc.svg")
+ ("Top level" . "symbol-misc.svg"))
+ "Mapping each Helm-imenu item type to the corresponding VSCode icon.")
+
(defvar helm-source-imenu nil "See (info \"(emacs)Imenu\")")
(defvar helm-source-imenu-all nil)
@@ -308,17 +391,54 @@ string."
"Function"
"Top level")
k))
- for disp1 = (mapconcat
- (lambda (x)
- (propertize
- x 'face
- (cl-loop for (p . f) in helm-imenu-type-faces
- when (string-match p x) return f
- finally return 'default)))
- types helm-imenu-delimiter)
+ for disp1 = (cond
+ (helm-imenu-show-icons
+ (let* ((icon (assoc-default (car types)
+ helm-imenu-icons-mapping))
+ (icon (if (null icon) "symbol-misc.svg" icon))
+ (dfw (default-font-width))
+ (size (cond
+ ((integerp company-icon-size)
+ company-icon-size)
+ ((and (consp company-icon-size)
+ (eq 'auto-scale
+ (car company-icon-size)))
+ (let ((base-size (cdr
company-icon-size))
+ (dfh (default-font-height)))
+ (min (if (> dfh (* 2 base-size))
+ (* 2 base-size)
+ base-size)
+ (* company-icon-margin dfw))))))
+ (dir (expand-file-name
+ (if (equal (frame-parameter
+ nil 'background-mode)
+ 'dark)
+ "vscode-dark"
+ "vscode-light")
+ company-icons-root))
+ (spec (list 'image
+ :file (expand-file-name icon dir)
+ :type 'svg
+ :width size
+ :height size
+ :ascent 'center))
+ (type-icon (propertize " " 'display spec)))
+ (concat type-icon " "
+ (mapconcat 'identity (cdr types)
+ helm-imenu-delimiter))))
+ (t
+ (mapconcat
+ (lambda (x)
+ (propertize
+ x 'face
+ (cl-loop for (p . f) in helm-imenu-type-faces
+ when (string-match p x) return f
+ finally return 'default)))
+ types helm-imenu-delimiter)))
for disp = (propertize disp1 'help-echo bufname 'types types)
collect
(cons disp (cons k v))))
+
;;;###autoload
(defun helm-imenu ()
- [nongnu] elpa/helm updated (fb5c5b3f36 -> d5e9fbc8ab), ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm b34d725c3c 01/11: helm-imenu supports showing item types by icons,
ELPA Syncer <=
- [nongnu] elpa/helm f2b38c8804 02/11: helm-imenu only shows icons in graphical display, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm 75bfc4700a 07/11: update some icons, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm 7e223e3d8b 09/11: remove company, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm d5e9fbc8ab 11/11: Merge pull request #2516 from taquangtrung/master, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm ac21666150 05/11: update some icons, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm f235af5cd8 06/11: revert missing icons, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm 23399802ab 04/11: make all-the-icons icons smaller for helm-imenu, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm c6e23f75af 10/11: use shadow face for item-delimiter, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm c981699d85 08/11: update all the icons, ELPA Syncer, 2022/05/31
- [nongnu] elpa/helm 8f483461d2 03/11: use all-the-icons for Helm-imenu, ELPA Syncer, 2022/05/31