sebastiencs / company-box

A company front-end with icons
561 stars 64 forks source link

support icons for CIDER company-backend #115

Closed stardiviner closed 4 years ago

stardiviner commented 4 years ago

Don't know why, can't display some type icons.

For example Document

image

But can display some other icons:

image

stardiviner commented 4 years ago

I changed Document icon into Template. Now they displays fine.

stardiviner commented 4 years ago

Can't display Namespace icon too.

image

sebastiencs commented 4 years ago

Thanks @stardiviner , do you know if thoses missing icons are missing too with other backends (other than cider) ?

stardiviner commented 4 years ago

Don't know other programming languages, I only tried Elisp, Clojure, and Python, don't know how other languages. Lucky that Python I have lsp-mode setup. So I tried following modification:

;;; modified
(setq company-box-icons--lsp-alist
      '((1 . Text)
        (2 . Document) ; <-- modified
        (3 . Document) ; <-- modified
        (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)))

I tested all image filenames in images/ directory.

Confirmed Document, ColorPalette, Enumerator, EnumItem, LocalVariable, Misc, Namespace, String. All of those icon images not working. (I'm currently using lates source code version of company-box.)

sebastiencs commented 4 years ago

Ah, I see where is your confusion now. The symbols Text, Method, Function, .. are referring to an item kind, not an image or file. Search for "CompletionItemKind" on the lsp specification.

Each kind (Text, Method, ..) is then associated to a file with the variables company-box-icons-{images,idea,eclipse,netbeans} (in company-box-icons.el)

stardiviner commented 4 years ago

The symbols Text, Method, Function, .. are referring to an item kind, not an image or file.

I think LSP use numbers as referering to item kind. So the cdr of alist like Method should be refer to icon image filename. That's how company-box-icons--lsp-alist alist defined. And I write my code followed company-box-icons--acphp and company-box-icons--lsp. They use (get-text-property 0 'lsp-completion-item candidate) to get candidate item type. And cider-completion-annotations-alist also defined the CIDER avaiable item types.

If my code write wrong, why some icons display fine, and some of them doesn't? After your explaination, it gets me more confused....

stardiviner commented 4 years ago

I thinked about your explaination and reviewed the code of company-box-icons.el. Finally understand your explaination. Thanks for that.

My PR code is fine. still weird that why some icons can't be displayed.

sebastiencs commented 4 years ago

For company-box-icons--cider-alist you need to use symbols defined here: image

Misc, Enumerator, ... are not valid

stardiviner commented 4 years ago

Thanks @sebastiencs , finally resolved this issue. I'm glad to see it. :+1:

P.S. This is the first time I realized there are some candidate type items are using same icons. Is it possible to add more different icon images?

sebastiencs commented 4 years ago

The default images (company-box-icons-images) were taken from vscode. Looks like they are now in a new repository https://github.com/microsoft/vscode-icons since I grabbed them. If you're willing to update them please do.

If you want to make a complete new set of icons, please add a new variable, similar to company-box-icons-netbeans, company-box-icons-idea etc.

sebastiencs commented 4 years ago

Thank you @stardiviner