-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Some configuration ideas for kind-icon
.
To use icons from nerd-fonts
, you need to configure svg-lib
, the library kind-icon
uses to download SVGs. In particular, you must add an entry or entries to the svg-lib-icon-collections
option.
For instance, to use nerd fonts' codicons set requires the following:
(require 'svg-lib)
(add-to-list 'svg-lib-icon-collections
'("nerd-fonts-codicons" . "https://github.com/microsoft/vscode-codicons/raw/HEAD/src/icons/%s.svg"))
This makes svg-lib
aware of a collection of icons we've named "nerd-fonts-codicons"
. The URL is unique to the GitHub repository where these icons are located; it points to the "microsoft/vscode-codicons" GitHub repository and the "src/icons" directory at the repository's HEAD. The "%s" is a placeholder for the name of the icons available in this directory. With this we can now set kind-icon-mapping
:
(setq kind-icon-mapping
'((array "a" :icon "symbol-array" :face font-lock-type-face :collection "nerd-fonts-codicons")
(boolean "b" :icon "symbol-boolean" :face font-lock-builtin-face :collection "nerd-fonts-codicons")
(color "#" :icon "symbol-color" :face success :collection "nerd-fonts-codicons")
(command "cm" :icon "chevron-right" :face default :collection "nerd-fonts-codicons")
(constant "co" :icon "symbol-constant" :face font-lock-constant-face :collection "nerd-fonts-codicons")
(class "c" :icon "symbol-class" :face font-lock-type-face :collection "nerd-fonts-codicons")
(constructor "cn" :icon "symbol-method" :face font-lock-function-name-face :collection "nerd-fonts-codicons")
(enum "e" :icon "symbol-enum" :face font-lock-builtin-face :collection "nerd-fonts-codicons")
(enummember "em" :icon "symbol-enum-member" :face font-lock-builtin-face :collection "nerd-fonts-codicons")
(enum-member "em" :icon "symbol-enum-member" :face font-lock-builtin-face :collection "nerd-fonts-codicons")
(event "ev" :icon "symbol-event" :face font-lock-warning-face :collection "nerd-fonts-codicons")
(field "fd" :icon "symbol-field" :face font-lock-variable-name-face :collection "nerd-fonts-codicons")
(file "f" :icon "symbol-file" :face font-lock-string-face :collection "nerd-fonts-codicons")
(folder "d" :icon "folder" :face font-lock-doc-face :collection "nerd-fonts-codicons")
(function "f" :icon "symbol-method" :face font-lock-function-name-face :collection "nerd-fonts-codicons")
(interface "if" :icon "symbol-interface" :face font-lock-type-face :collection "nerd-fonts-codicons")
(keyword "kw" :icon "symbol-keyword" :face font-lock-keyword-face :collection "nerd-fonts-codicons")
(macro "mc" :icon "lambda" :face font-lock-keyword-face)
(magic "ma" :icon "lightbulb-autofix" :face font-lock-builtin-face :collection "nerd-fonts-codicons")
(method "m" :icon "symbol-method" :face font-lock-function-name-face :collection "nerd-fonts-codicons")
(module "{" :icon "file-code-outline" :face font-lock-preprocessor-face)
(numeric "nu" :icon "symbol-numeric" :face font-lock-builtin-face :collection "nerd-fonts-codicons")
(operator "op" :icon "symbol-operator" :face font-lock-comment-delimiter-face :collection "nerd-fonts-codicons")
(param "pa" :icon "gear" :face default :collection "nerd-fonts-codicons")
(property "pr" :icon "symbol-property" :face font-lock-variable-name-face :collection "nerd-fonts-codicons")
(reference "rf" :icon "library" :face font-lock-variable-name-face :collection "nerd-fonts-codicons")
(snippet "S" :icon "symbol-snippet" :face font-lock-string-face :collection "nerd-fonts-codicons")
(string "s" :icon "symbol-string" :face font-lock-string-face :collection "nerd-fonts-codicons")
(struct "%" :icon "symbol-structure" :face font-lock-variable-name-face :collection "nerd-fonts-codicons")
(text "tx" :icon "symbol-key" :face font-lock-doc-face :collection "nerd-fonts-codicons")
(typeparameter "tp" :icon "symbol-parameter" :face font-lock-type-face :collection "nerd-fonts-codicons")
(type-parameter "tp" :icon "symbol-parameter" :face font-lock-type-face :collection "nerd-fonts-codicons")
(unit "u" :icon "symbol-ruler" :face font-lock-constant-face :collection "nerd-fonts-codicons")
(value "v" :icon "symbol-enum" :face font-lock-builtin-face :collection "nerd-fonts-codicons")
(variable "va" :icon "symbol-variable" :face font-lock-variable-name-face :collection "nerd-fonts-codicons")
(t "." :icon "question" :face font-lock-warning-face :collection "nerd-fonts-codicons")))
This tells kind-icon
to ask svg-lib
to use the icons named "symbol-array," "symbol-boolean," etc. from the "nerd-fonts-codicons" svg-lib
collection.
To use other icon sets from nerd-fonts, check the available glyph sets offered by nerd-fonts and change the URL of the collection added to svg-lib-icon-collections
appropriately. (Note that different icon collections may offer more or fewer icons, and those icons may have different names from the above, meaning users may need to
change the icon names in kind-icon-mapping
accordingly.)
You can use kind-icon
via a font (e.g. without SVG support), by installing and using a NerdFont. If you configure your terminal to use your nerd font, kind-icon will work there too.
Simply install nerd-icons
and use its instructions to configure.
One can use VS Code icons provided by https://github.com/microsoft/vscode-icons instead of the default Material icons set, if preferred.
Using modus-vivendi
and modus-operandi
themes (built-in Emacs 28+)
Simply tweak the variable kind-icon-mapping
in your init.el
like this:
(setq kind-icon-mapping
'((array "a" :icon "symbol-array" :face font-lock-type-face :collection "vscode")
(boolean "b" :icon "symbol-boolean" :face font-lock-builtin-face :collection "vscode")
(color "#" :icon "symbol-color" :face success :collection "vscode")
(command "cm" :icon "chevron-right" :face default :collection "vscode")
(constant "co" :icon "symbol-constant" :face font-lock-constant-face :collection "vscode")
(class "c" :icon "symbol-class" :face font-lock-type-face :collection "vscode")
(constructor "cn" :icon "symbol-method" :face font-lock-function-name-face :collection "vscode")
(enum "e" :icon "symbol-enum" :face font-lock-builtin-face :collection "vscode")
(enummember "em" :icon "symbol-enum-member" :face font-lock-builtin-face :collection "vscode")
(enum-member "em" :icon "symbol-enum-member" :face font-lock-builtin-face :collection "vscode")
(event "ev" :icon "symbol-event" :face font-lock-warning-face :collection "vscode")
(field "fd" :icon "symbol-field" :face font-lock-variable-name-face :collection "vscode")
(file "f" :icon "symbol-file" :face font-lock-string-face :collection "vscode")
(folder "d" :icon "folder" :face font-lock-doc-face :collection "vscode")
(function "f" :icon "symbol-method" :face font-lock-function-name-face :collection "vscode")
(interface "if" :icon "symbol-interface" :face font-lock-type-face :collection "vscode")
(keyword "kw" :icon "symbol-keyword" :face font-lock-keyword-face :collection "vscode")
(macro "mc" :icon "lambda" :face font-lock-keyword-face)
(magic "ma" :icon "lightbulb-autofix" :face font-lock-builtin-face :collection "vscode")
(method "m" :icon "symbol-method" :face font-lock-function-name-face :collection "vscode")
(module "{" :icon "file-code-outline" :face font-lock-preprocessor-face)
(numeric "nu" :icon "symbol-numeric" :face font-lock-builtin-face :collection "vscode")
(operator "op" :icon "symbol-operator" :face font-lock-comment-delimiter-face :collection "vscode")
(param "pa" :icon "gear" :face default :collection "vscode")
(property "pr" :icon "symbol-property" :face font-lock-variable-name-face :collection "vscode")
(reference "rf" :icon "library" :face font-lock-variable-name-face :collection "vscode")
(snippet "S" :icon "symbol-snippet" :face font-lock-string-face :collection "vscode")
(string "s" :icon "symbol-string" :face font-lock-string-face :collection "vscode")
(struct "%" :icon "symbol-structure" :face font-lock-variable-name-face :collection "vscode")
(text "tx" :icon "symbol-key" :face font-lock-doc-face :collection "vscode")
(typeparameter "tp" :icon "symbol-parameter" :face font-lock-type-face :collection "vscode")
(type-parameter "tp" :icon "symbol-parameter" :face font-lock-type-face :collection "vscode")
(unit "u" :icon "symbol-ruler" :face font-lock-constant-face :collection "vscode")
(value "v" :icon "symbol-enum" :face font-lock-builtin-face :collection "vscode")
(variable "va" :icon "symbol-variable" :face font-lock-variable-name-face :collection "vscode")
(t "." :icon "question" :face font-lock-warning-face :collection "vscode")))
Note that for the macro
and module
items, no really good options were available in the VS Code icons set, therefore only these two will keep using their Material counterparts.
In case the icons appear too big in the Corfu completion childframe, you can adjust the height like this (default 1
):
(plist-put kind-icon-default-style :height 0.9)