company-box
company-box copied to clipboard
all-the-icons integration?
There's an all the icons library which provides a more or less standard (It is used by at least 4 packages on MELPA) way to show icons in emacs. It also has an installable (right from Emacs) collection of icon fonts. I think it would be great to reuse its possibilities in company-box too.
Thank you.
@a13 It's supposed to be already possible.
I didn't tested, but can you try:
(setq company-box-icons-elisp
(list
(all-the-icons-octicon "file-binary")
(all-the-icons-faicon "cogs")
(all-the-icons-wicon "tornado")
(all-the-icons-wicon "tornado")))
If it works, can you share the icons you use so I can update the wiki with all-the-icons
variables
well, It kind of works.
I realized that you use hardcoded icons, not the best approach, TMM, It would be better to use something like
(defvar company-box-icons-images
`((Text . ,(company-box-icons-image "String.png"))
(Method . ,(company-box-icons-image "Method.png"))
(Function . ,(company-box-icons-image "Method.png"))
(Constructor . ,(company-box-icons-image "Method.png"))
;; … and so on
))
(defvar company-box-icons-all-the-icons
`((Text (all-the-icons-octicon "file-binary"))
…
))
;; alist we use to get icon from kind, better be defcustom
(defvar company-box-icons-alist company-box-icons-all-the-icons)
So when we try to get an icon for elisp, we can use smth like
(defun company-box-icons--elisp (candidate)
(when (derived-mode-p 'emacs-lisp-mode)
(let* ((sym (intern candidate))
;; we even can move it to (predicate . kind) alist
(kind (cond ((fboundp sym) 'Function)
((boundp sym) 'Variable)
((featurep sym) 'Module)
((facep sym) 'Color))))
(when kind
(alist-get kind company-box-icons-alist)))))
and for LSP
(defconst company-box-icons-completion-item-kind-alist
'((1 . Text)
(2 . Method)
(3 . Function)
(4 . Constructor)
(5 . Field)
(6 . Variable)
(7 . Class)
(8 . Interface)
(9 . Property)
(10 . Module)
(11 . Unit)
(12 . Value)
(13 . Enum)
(14 . Keyword)
(15 . Snippet)
(16 . Color)
(17 . File)
(18 . Reference)
(19 . Folder)
(20 . EnumMember)
(21 . Constant)
(22 . Struct)
(23 . Event)
(24 . Operator)
(25 . TypeParameter)))
(defun company-box-icons--lsp (candidate)
(-when-let* ((lsp-item (get-text-property 0 'lsp-completion-item candidate))
(kind-num (gethash "kind" lsp-item))
(kind (alist-get kind-num company-box-icons-completion-item-kind-alist)))
;; this part is the same, so we can move it to the top-level
(alist-get kind company-box-icons-alist)))
Not sure if "hardcoded" is the right word but yeah your idea is way better. I will change that, unless you want to make a PR ?
well, It kind of works.
What do you mean exactly ? Are the icons not properly display ?
I will change that unless you want to make a PR?
I'd like to, but sadly I don't have time right now, so It's up to you, thanks!
Are the icons not properly display
The problem is not with icons, it constantly breaks up with
Debugger entered--Lisp error: (invalid-function company-box--get-frame)
company-box--get-frame()
company-box-doc--show(0 #<frame *scratch* 0x5d57d80>)
#f(compiled-function () #<bytecode 0xcc434f1>)()
apply(#f(compiled-function () #<bytecode 0xcc434f1>) nil)
timer-event-handler([t 0 0 500000 nil #f(compiled-function () #<bytecode 0xcc434f1>) nil idle 0])
redisplay(t)
company-box--point-bottom()
company-box--set-frame-position(#<frame emacs@tp430 0xa061210>)
company-box--display(#(" def-edebug-spec\n def-moving-action\n def-point-im-avy-jump\n def-projectile-commander-method\n def-simple-action\n defadvice\n defalias\n defapidelete-ghubp\n defapiget-ghubp\n defapihead-ghubp" 0 1 (company-box--color nil company-box--len 15 display (space :width 0.75)) 1 2 (company-box--color nil company-box--len 15 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 2 3 (company-box--color nil company-box--len 15 display (space :align-to (+ left-fringe 3))) 3 6 (company-box--color nil company-box--len 15 face company-box-candidate) 6 7 (company-box--color nil company-box--len 15 face company-box-candidate) 7 18 (company-box--color nil company-box--len 15 face company-box-candidate) 19 20 (company-box--color nil company-box--len 17 display (space :width 0.75)) 20 21 (company-box--color nil company-box--len 17 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 21 22 (company-box--color nil company-box--len 17 display (space :align-to (+ left-fringe 3))) 22 25 (company-box--color nil company-box--len 17 face company-box-candidate) 25 26 (company-box--color nil company-box--len 17 face company-box-candidate) 26 39 (company-box--color nil company-box--len 17 face company-box-candidate) 40 41 (company-box--color nil company-box--len 21 display (space :width 0.75)) 41 42 (company-box--color nil company-box--len 21 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 42 43 (company-box--color nil company-box--len 21 display (space :align-to (+ left-fringe 3))) 43 46 (company-box--color nil company-box--len 21 face company-box-candidate) 46 47 (company-box--color nil company-box--len 21 face company-box-candidate) 47 64 (company-box--color nil company-box--len 21 face company-box-candidate) 65 66 (company-box--color nil company-box--len 31 display (space :width 0.75)) 66 67 (company-box--color nil company-box--len 31 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 67 68 (company-box--color nil company-box--len 31 display (space :align-to (+ left-fringe 3))) 68 71 (company-box--color nil company-box--len 31 face company-box-candidate) 71 72 (company-box--color nil company-box--len 31 face company-box-candidate) 72 99 (company-box--color nil company-box--len 31 face company-box-candidate) 100 101 (company-box--color nil company-box--len 17 display (space :width 0.75)) 101 102 (company-box--color nil company-box--len 17 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 102 103 (company-box--color nil company-box--len 17 display (space :align-to (+ left-fringe 3))) 103 106 (company-box--color nil company-box--len 17 face company-box-candidate) 106 107 (company-box--color nil company-box--len 17 face company-box-candidate) 107 120 (company-box--color nil company-box--len 17 face company-box-candidate) 121 122 (company-box--color nil company-box--len 9 display (space :width 0.75)) 122 123 (company-box--color nil company-box--len 9 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 123 124 (company-box--color nil company-box--len 9 display (space :align-to (+ left-fringe 3))) 124 127 (company-box--color nil company-box--len 9 face company-box-candidate) 127 128 (company-box--color nil company-box--len 9 face company-box-candidate) 128 133 (company-box--color nil company-box--len 9 face company-box-candidate) 134 135 (company-box--color nil company-box--len 8 display (space :width 0.75)) 135 136 (company-box--color nil company-box--len 8 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 136 137 (company-box--color nil company-box--len 8 display (space :align-to (+ left-fringe 3))) 137 140 (company-box--color nil company-box--len 8 face company-box-candidate) 140 141 (company-box--color nil company-box--len 8 face company-box-candidate) 141 145 (company-box--color nil company-box--len 8 face company-box-candidate) 146 147 (company-box--color nil company-box--len 18 display (space :width 0.75)) 147 148 (company-box--color nil company-box--len 18 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 148 149 (company-box--color nil company-box--len 18 display (space :align-to (+ left-fringe 3))) 149 152 (company-box--color nil company-box--len 18 face company-box-candidate) 152 153 (company-box--color nil company-box--len 18 face company-box-candidate) 153 167 (company-box--color nil company-box--len 18 face company-box-candidate) 168 169 (company-box--color nil company-box--len 15 display (space :width 0.75)) 169 170 (company-box--color nil company-box--len 15 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 170 171 (company-box--color nil company-box--len 15 display (space :align-to (+ left-fringe 3))) 171 174 (company-box--color nil company-box--len 15 face company-box-candidate) 174 175 (company-box--color nil company-box--len 15 face company-box-candidate) 175 186 (company-box--color nil company-box--len 15 face company-box-candidate) 187 188 (company-box--color nil company-box--len 16 display (space :width 0.75)) 188 189 (company-box--color nil company-box--len 16 face (:family "github-octicons" :height 1.2) display (raise -0.24) rear-nonsticky t font-lock-ignore t) 189 190 (company-box--color nil company-box--len 16 display (space :align-to (+ left-fringe 3))) 190 193 (company-box--color nil company-box--len 16 face company-box-candidate) 193 194 (company-box--color nil company-box--len 16 face company-box-candidate) 194 206 (company-box--color nil company-box--len 16 face company-box-candidate)))
company-box-show()
company-box-frontend(update)
company-call-frontends(update)
company--perform()
company-auto-begin()
company-idle-begin(#<buffer *scratch*> #<window 218 on *scratch*> 58729 2293)
apply(company-idle-begin (#<buffer *scratch*> #<window 218 on *scratch*> 58729 2293))
timer-event-handler([t 23230 8433 635872 nil company-idle-begin (#<buffer *scratch*> #<window 218 on *scratch*> 58729 2293) nil 408000])
I use GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2018-03-14
hey there! any news on refactoring?
It seems the project is dead 😢
After I reviewed the PR, I realized the codes are not good enough. Many icons are missing, and some icons are not quite good and meaningful. Another issue is company-box-color-icon
is disrespected.
I have to customize myself. Attach here for reference:
(setq company-box-icons-lsp
`(( 1 . ,(all-the-icons-faicon "file-text-o" :v-adjust -0.0575)) ; Text
( 2 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Method
( 3 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Function
( 4 . ,(all-the-icons-faicon "cube" :v-adjust -0.0575)) ; Constructor
( 5 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Field
( 6 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Variable
( 7 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; Class
( 8 . ,(all-the-icons-faicon "cogs" :v-adjust -0.0575)) ; Interface
( 9 . ,(all-the-icons-alltheicon "less")) ; Module
(10 . ,(all-the-icons-faicon "wrench" :v-adjust -0.0575)) ; Property
(11 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Unit
(12 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Value
(13 . ,(all-the-icons-material "content_copy" :v-adjust -0.2)) ; Enum
(14 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Keyword
(15 . ,(all-the-icons-material "content_paste" :v-adjust -0.2)) ; Snippet
(16 . ,(all-the-icons-material "palette" :v-adjust -0.2)) ; Color
(17 . ,(all-the-icons-faicon "file" :v-adjust -0.0575)) ; File
(18 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Reference
(19 . ,(all-the-icons-faicon "folder" :v-adjust -0.0575)) ; Folder
(20 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; EnumMember
(21 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Constant
(22 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; Struct
(23 . ,(all-the-icons-faicon "bolt" :v-adjust -0.0575)) ; Event
(24 . ,(all-the-icons-faicon "tag" :v-adjust -0.0575)) ; Operator
(25 . ,(all-the-icons-faicon "cog" :v-adjust -0.0575)) ; TypeParameter
))
@seagle0128 you can fork my fork and then make your own PR
This can be closed.