Alexander Courtis 0bb67ef952
feat(#192): :NvimWebDeviconsHiTest (#405)
* feat(#192): :NvimWebDeviconsHiTest

* feat(#192): :NvimWebDeviconsHiTest
2024-02-25 16:00:17 +11:00
.github/workflows ci: luarocks release plumbing 2024-01-15 15:21:53 +11:00
lua feat(#192): :NvimWebDeviconsHiTest (#405) 2024-02-25 16:00:17 +11:00
plugin feat: implement lazy-loading when get_icon is called 2020-10-28 12:02:51 +01:00
scripts feat: operating system icons (#362) 2023-12-30 11:36:20 +11:00
.editorconfig ci: style, lint dev: precommit, style, lint, editorconfig (#218) 2023-03-20 12:32:18 +11:00
.gitignore ci: use vim-colortemplate tarball rather than git clone (#347) 2023-11-27 13:25:41 +11:00
.luacheckrc ci: style, lint dev: precommit, style, lint, editorconfig (#218) 2023-03-20 12:32:18 +11:00
.luarc.json ci: style, lint dev: precommit, style, lint, editorconfig (#218) 2023-03-20 12:32:18 +11:00
.pre-commit-config.yaml chore: update pre-commit hooks (#385) 2024-01-24 05:56:00 +01:00
.stylua.toml ci: style, lint dev: precommit, style, lint, editorconfig (#218) 2023-03-20 12:32:18 +11:00 feat(#192): :NvimWebDeviconsHiTest (#405) 2024-02-25 16:00:17 +11:00
LICENSE MIT license 2023-01-07 10:02:52 +11:00
Makefile ci: use vim-colortemplate tarball rather than git clone (#347) 2023-11-27 13:25:41 +11:00 feat(#192): :NvimWebDeviconsHiTest (#405) 2024-02-25 16:00:17 +11:00


Nerd fonts moved some symbols with version 3.0. Version 2.3 is meant for transition, supporting both version 2 and version 3 icons.

Nvim-web-devicons requires version 2.3 or above to work properly. If you are unable to update please use your plugin manager to pin version of nvim-web-dev icons to nerd-v2-compat tag.


A lua fork of vim-devicons. This plugin provides the same icons as well as colors for each icon.

Light and dark color variants are provided.



Plug 'nvim-tree/nvim-web-devicons'

or with packer.nvim

use 'nvim-tree/nvim-web-devicons'




Run :NvimWebDeviconsHiTest to see all icons and their highlighting.


Light or dark color variants of the icons depend on &background.

The variant is updated:

  • on OptionSet event for background, or
  • after explicitly calling require("nvim-web-devicons").refresh().

However, be advised that the plugin using nvim-web-devicons may have cached the icons.


This adds all the highlight groups for the devicons i.e. it calls vim.api.nvim_set_hl for all icons this might need to be re-called in a Colorscheme to re-apply cleared highlights if the color scheme changes

require'nvim-web-devicons'.setup {
 -- your personnal icons can go here (to override)
 -- you can specify color or cterm_color instead of specifying both of them
 -- DevIcon will be appended to `name`
 override = {
  zsh = {
    icon = "",
    color = "#428850",
    cterm_color = "65",
    name = "Zsh"
 -- globally enable different highlight colors per icon (default to true)
 -- if set to false all icons will have the default icon's color
 color_icons = true;
 -- globally enable default icons (default to false)
 -- will get overriden by `get_icons` option
 default = true;
 -- globally enable "strict" selection of icons - icon will be looked up in
 -- different tables, first by filename, and if not found by extension; this
 -- prevents cases when file doesn't have any extension but still gets some icon
 -- because its name happened to match some extension (default to false)
 strict = true;
 -- same as `override` but specifically for overrides by filename
 -- takes effect when `strict` is true
 override_by_filename = {
  [".gitignore"] = {
    icon = "",
    color = "#f1502f",
    name = "Gitignore"
 -- same as `override` but specifically for overrides by extension
 -- takes effect when `strict` is true
 override_by_extension = {
  ["log"] = {
    icon = "",
    color = "#81e043",
    name = "Log"

Get Icon

Get the icon for a given file by passing in the name, the extension and an optional options table. The name is passed in to check for an exact match e.g. .bashrc if there is no exact name match the extension is used. Calls .setup() if it hasn't already ran.

require'nvim-web-devicons'.get_icon(filename, extension, options)

The optional options argument can used to change how the plugin works the keys include default = <boolean> and strict = <boolean>. If the default key is set to true this function will return a default if there is no matching icon. If the strict key is set to true this function will lookup icon specifically by filename, and if not found then specifically by extension, and fallback to default icon if default key is set to true. e.g.

require'nvim-web-devicons'.get_icon(filename, extension, { default = true })

You can check if the setup function was already called with:


Get icon and color code

get_icon_color differs from get_icon only in the second return value. get_icon_cterm_color returns cterm color instead of gui color get_icon returns icon and highlight name. If you want to get color code, you can use this function.

local icon, color = require'nvim-web-devicons'.get_icon_color("init.lua", "lua")
assert(icon == "")
assert(color == "#51a0cf")

Get all icons

It is possible to get all of the registered icons with the get_icons() function:


This can be useful for debugging purposes or for creating custom highlights for each icon.

Set an icon

You can override individual icons with the set_icon({...}) function:

require("nvim-web-devicons").set_icon {
  zsh = {
    icon = "",
    color = "#428850",
    cterm_color = "65",
    name = "Zsh"

You can override the default icon with the set_default_icon(icon, color, cterm_color) function:

require("nvim-web-devicons").set_default_icon('', '#6d8086', 65)

Getting icons by filetype

You can get the icon and colors associated with a filetype using the by_filetype functions:

require("nvim-web-devicons").get_icon_by_filetype(filetype, opts)
require("nvim-web-devicons").get_icon_colors_by_filetype(filetype, opts)
require("nvim-web-devicons").get_icon_color_by_filetype(filetype, opts)
require("nvim-web-devicons").get_icon_cterm_color_by_filetype(filetype, opts)

These functions are the same as their counterparts without the _by_filetype suffix, but they take a filetype instead of a name/extension.

You can also use get_icon_name_by_filetype(filetype) to get the icon name associated with the filetype.


PRs are always welcome! Please see CONTRIBUTING