Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Provides Nerd Font icons (glyphs) for use by neovim plugins

License

NotificationsYou must be signed in to change notification settings

Natzgun/nvim-web-devicons

 
 

Repository files navigation

ProvidesNerd Font1 icons (glyphs) for use byNeovim plugins:

  • Icons by:
    • Extension
    • Full name
  • Colours
  • Light and dark variants
  • API to modify/add icons

Alua fork ofvim-devicons.

Tip

nvim-web-devicons adds new icons as they are introduced to Nerd Fonts. Please ensure that you are using the latest version of the font as newly introduced icons may display incorrectly or as an "unknown character".

Important

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 updateplease use your plugin manager to pin version of nvim-web-dev icons tonerd-v2-compat tag.

Requirements

Installation

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

or withpacker.nvim

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

or withlazy.nvim

{"nvim-tree/nvim-web-devicons",opts= {} },

LuaRocks

Additional Icons

Additional icons may be added for icons that are present in Nerd Fonts: use theCheat Sheet search for available icons.

PRs are always welcome! Please seeCONTRIBUTING

Important

If the icon you need is not available on Nerd Fonts you first need to make aPR to a project that feeds glyphs to Nerd Fonts. Probably the most adequateproject to contribute ishttps://github.com/devicons/devicon.Take into account thatmonths can pass before the icon is available on theNerd Fonts project, once there feel free to open a PR on this project, seeCONTRIBUTING

Usage

Viewing

Run:NvimWebDeviconsHiTest to see all icons and their highlighting.

Variants

Light or dark color variants of the icons depend on&background.
The variant can also be set manually insetup with thevariant option.

The variant is updated:

  • onOptionSet event forbackground, or
  • after explicitly callingrequire("nvim-web-devicons").refresh().

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

Case Sensitivity

Filename icons e.g."Dockerfile" are case insensitively matched.

Extension icons e.g."lua" are case sensitive.

Setup

This adds all the highlight groups for the deviconsi.e. it callsvim.api.nvim_set_hl for all iconsthis might need to be re-called in aColorscheme to re-apply cleared highlightsif the color scheme changes

require'nvim-web-devicons'.setup {-- your personal 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 colorcolor_icons=true;-- globally enable default icons (default to false)-- will get overriden by `get_icons` optiondefault=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;-- set the light or dark variant manually, instead of relying on `background`-- (default to nil)variant="light|dark";-- same as `override` but specifically for overrides by filename-- takes effect when `strict` is trueoverride_by_filename= {  [".gitignore"]= {icon="",color="#f1502f",name="Gitignore"  } };-- same as `override` but specifically for overrides by extension-- takes effect when `strict` is trueoverride_by_extension= {  ["log"]= {icon="",color="#81e043",name="Log"  } };-- same as `override` but specifically for operating system-- takes effect when `strict` is trueoverride_by_operating_system= {  ["apple"]= {icon="",color="#A2AAAD",cterm_color="248",name="Apple",  }, };}

Get Icon

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

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

The optionaloptions argument can used to change how the plugin works the keys includedefault = <boolean> andstrict = <boolean>. If the default key is set to true thisfunction will return a default if there is no matching icon. If the strict key is setto true this function will lookup icon specifically by filename, and if not found thenspecifically 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:

require'nvim-web-devicons'.has_loaded()

Get icon and color code

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

localicon,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 theget_icons() function:

require'nvim-web-devicons'.get_icons()

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

Mapped categories can be fetched via:

require'nvim-web-devicons'.get_icons_by_filename()require'nvim-web-devicons'.get_icons_by_extension()require'nvim-web-devicons'.get_icons_by_operating_system()require'nvim-web-devicons'.get_icons_by_desktop_environment()require'nvim-web-devicons'.get_icons_by_window_manager()

Set an icon

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

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

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

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

Getting and setting icons by filetype

You can get the icon and colors associated with a filetype using theby_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)

or set the icon to use for a filetype with:

require("nvim-web-devicons").set_icon_by_filetype {cpp="c",pandoc="md", }

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 useget_icon_name_by_filetype(filetype) to get the icon name associated with the filetype.

Known Issues

Mysetup Overrides Are Not Applied

Cause: A plugin may be calling nvim-web-deviconssetup before you do. Yoursetup call will be ignored.

Workaround: Call nvim-web-deviconssetup before the plugin's ownsetup.

Windows and WSL not rendering icons properly on some terminals

On Windows and WSL, it is possible that the icons are not rendered properly whenusing a terminal that relies on Windows' default system libraries. An exampleof this is Alacritty (#271).Other terminals (e.g. Windows Terminal, and WezTerm) do no have this issue, asthey ship newer versions of these libraries. More precisely, they use newerversions ofconpty.dll andOpenConsole.exe. So, as a workaround to therendering issue, you need to make your terminal use these newer files. Whetherthis is possible depends on the terminal you are using. Please refer to theterminal's documentation for this.

In the specific case of Alacritty, you need to place up-to-dateconpty.dll andOpenConsole.exe files in yourPATH. Microsoft does not provide these filesdirectly, but you can get them from other terminal emulators that ship them.

Contributing

PRs are always welcome! Please seeCONTRIBUTING

Footnotes

  1. Not limited to Nerd Font icons: unicode and other fonts may be used.

About

Provides Nerd Font icons (glyphs) for use by neovim plugins

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua98.1%
  • Makefile1.1%
  • Other0.8%

[8]ページ先頭

©2009-2025 Movatter.jp