doomemacs / doomemacs/core

Icons not showing when `:completion company +childframe` and Emacs daemon + **Workaround**

Open
#6,668 1 comment 0 reactions 0 assignees View on GitHub
:completion company is:bug re:emacs:daemon
Dominant language
Emacs Lisp
Stars
22.7k
Forks
3.1k
Avg merge
10h 46m
Merged PRs (30d)
4

Description

### What did you expect to happen?

See icons in `company/company-box`'s completion after launching Emacs client.

### What actually happened?

### When I run `emacs`, I have these nice icons:
![Screenshot_20220812_153728](https://user-images.githubusercontent.com/3716399/184367019-e9cc1513-6fa9-45ed-b3ae-b941f4c39a82.png)

### When I start `emacs --daemon`, then `emacsclient -c`, I have no icons:
![Screenshot_20220812_153914](https://user-images.githubusercontent.com/3716399/184367036-63ac8bbe-62ef-4777-9f2c-0eddab6d94b8.png)

### Describe your attempts to resolve the issue

**EDIT:** After some investigations, I found out that, `company-box-icons-alist` points to `company-box-icons-all-the-icons` and the last is modified in Doom's `completion/company/config.el`, but the weird thing is, when I evaluate `company-box-icons-all-the-icons` from an Emacs client running with a daemon, I get a list of empty string icons:

```elisp
((Unknown . "") (Text . "") (Method . "") (Function . "")
(Constructor . "") (Field . "") (Variable . "") (Class . "")
(Interface . "") (Module . "") (Property . "") (Unit . "") (Value . "")
(Enum . "") (Keyword . "") (Snippet . "") (Color . "") (File . "")
(Reference . "") (Folder . "") (EnumMember . "") (Constant . "")
(Struct . "") (Event . "") (Operator . "") (TypeParameter . "")
(Template . "") (ElispFunction . "") (ElispVariable . "")
(ElispFeature . "") (ElispFace . ""))
```

If I evaluate the `(setq company-box-icons-all-the-icons (let ...))` [from `completion/company/config.el`](https://github.com/doomemacs/doomemacs/blob/02bb28dc8207fc57fd7139d9d9727d26ae0680f4/modules/completion/company/config.el#L111-L143), the problem is resolved, and icons are shown in `company-box` **(in the current Emacs client instance)**.

So, I managed to find a workaround like this:

```elisp
(after! company-box
(defun +company-box-reload-icons ()
(message "[FIX] Reloaded `company-box-icons-all-the-icons'")
(setq company-box-icons-all-the-icons
(let ((all-the-icons-scale-factor 0.8))
`((Unknown . ,(all-the-icons-material "find_in_page" :face 'all-the-icons-purple))
(Text . ,(all-the-icons-material "text_fields" :face 'all-the-icons-green))
(Method . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
(Function . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
(Constructor . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
(Field . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
(Variable . ,(all-the-icons-material "adjust" :face 'all-the-icons-blue))
(Class . ,(all-the-icons-material "class" :face 'all-the-icons-red))
(Interface . ,(all-the-icons-material "settings_input_component" :face 'all-the-icons-red))
(Module . ,(all-the-icons-material "view_module" :face 'all-the-icons-red))
(Property . ,(all-the-icons-material "settings" :face 'all-the-icons-red))
(Unit . ,(all-the-icons-material "straighten" :face 'all-the-icons-red))
(Value . ,(all-the-icons-material "filter_1" :face 'all-the-icons-red))
(Enum . ,(all-the-icons-material "plus_one" :face 'all-the-icons-red))
(Keyword . ,(all-the-icons-material "filter_center_focus" :face 'all-the-icons-red))
(Snippet . ,(all-the-icons-material "short_text" :face 'all-the-icons-red))
(Color . ,(all-the-icons-material "color_lens" :face 'all-the-icons-red))
(File . ,(all-the-icons-material "insert_drive_file" :face 'all-the-icons-red))
(Reference . ,(all-the-icons-material "collections_bookmark" :face 'all-the-icons-red))
(Folder . ,(all-the-icons-material "folder" :face 'all-the-icons-red))
(EnumMember . ,(all-the-icons-material "people" :face 'all-the-icons-red))
(Constant . ,(all-the-icons-material "pause_circle_filled" :face 'all-the-icons-red))
(Struct . ,(all-the-icons-material "streetview" :face 'all-the-icons-red))
(Event . ,(all-the-icons-material "event" :face 'all-the-icons-red))
(Operator . ,(all-the-icons-material "control_point" :face 'all-the-icons-red))
(TypeParameter . ,(all-the-icons-material "class" :face 'all-the-icons-red))
(Template . ,(all-the-icons-material "short_text" :face 'all-the-icons-green))
(ElispFunction . ,(all-the-icons-material "functions" :face 'all-the-icons-red))
(ElispVariable . ,(all-the-icons-material "check_circle" :face 'all-the-icons-blue))
(ElispFeature . ,(all-the-icons-material "stars" :face 'all-the-icons-orange))
(ElispFace . ,(all-the-icons-material "format_paint" :face 'all-the-icons-pink))))))

(add-hook 'server-after-make-frame-hook #'+company-box-reload-icons))

```

### Steps to reproduce

1. Start `emacs --daemon`
2. Open `emacsclient -c`
3. Open a source file (Elisp for example)
4. Start typing until company's child frame shows up, there will be no icons!

### System Information

https://pastebin.com/p9LUCWmw

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.