nerd-icons-corfu
nerd-icons-corfu copied to clipboard
Icons for corfu via nerd-icons
#+title: nerd-icons-corfu.el - Icons for Corfu via nerd-icons #+author: Luigi Sartor Piucco #+language: en
[[https://melpa.org/#/nerd-icons-corfu][file:https://melpa.org/packages/nerd-icons-corfu-badge.svg]]
Nerd-icons-corfu.el is a library for adding icons to completions in [[https://github.com/minad/corfu][Corfu]]. It uses [[https://github.com/rainstormstudio/nerd-icons.el][nerd-icons.el]] under the hood and, as such, works on both GUI and terminal. Below if a screenshot of the GUI version.
[[file:screenshots/gui.png]]
Note that you need a [[https://www.nerdfonts.com/#home][Nerd Font]] installed for it to work.
- Usage ~nerd-icons-corfu~ is on [[https://melpa.org/#/nerd-icons-corfu][Melpa]]. You can install it with built-in ~M-x package-install~.
To use it, add ~nerd-icons-corfu-formatter~ to ~corfu-margin-formatters~, and maybe tweak the icons to your linking in ~nerd-icons-corfu-mapping~: #+begin_src emacs-lisp (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)
;; Optionally: (setq nerd-icons-corfu-mapping '((array :style "cod" :icon "symbol_array" :face font-lock-type-face) (boolean :style "cod" :icon "symbol_boolean" :face font-lock-builtin-face) ;; ... (t :style "cod" :icon "code" :face font-lock-warning-face))) ;; Remember to add an entry for `t', the library uses that as default.
;; The Custom interface is also supported for tuning the variable above. #+end_src
- Difference from ~kind-icon~ [[https://github.com/jdtsmith/kind-icon][kind-icon]] is another, more well-known package that adds icons to Corfu. At a glance, this package may seem redundant. However, there are key differences in goals and methods, outlined in the following:
- Though ~kind-icon~ focuses on Corfu, it's more-or-less agnostic, you can use it for ~company-mode~, for instance. This package is more limited in regard to scope: it implements icons for Corfu via Nerd Fonts, and only that.
- ~kind-icon~ uses [[https://github.com/rougier/svg-lib][svg-lib]] under the hood, and it actually draws images for the icons. There is overhead related to this and the method requires a graphical display (on terminal, it only adds plaintext), therefore being less portable. Here the provider is [[https://github.com/rainstormstudio/nerd-icons.el][nerd-icons.el]], and the icons are actually Unicode text with a special font.
Additionally, [[https://github.com/rainstormstudio/nerd-icons.el#use-nerd-icons-with-corfu][it is possible to use nerd-icons.el with kind-icon]], but the setup required is non-trivial, and it feels like overkill to bring in SVG drawing capabilities to render glyph text.
None of this is to say ~kind-icon~ is bad or worse, it's really a matter of taste, since its icons are indeed a bit more elaborate.