• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

kyazdani42/nvim-web-devicons: lua `fork` of vim-web-devicons for neovim

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

kyazdani42/nvim-web-devicons

开源软件地址(OpenSource Url):

https://github.com/kyazdani42/nvim-web-devicons

开源编程语言(OpenSource Language):

Lua 95.1%

开源软件介绍(OpenSource Introduction):

Nvim-web-devicons

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

Requirements

Installation

Plug 'kyazdani42/nvim-web-devicons'

Usage

Setup

This adds all the highlight groups for the devicons i.e. it calls highlight IconNameDevicon guifg='<color>' ctermfg='<cterm_color>' 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 default icons (default to false)
 -- will get overriden by `get_icons` option
 default = true;
}

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>. If the default key is set to true this function will return a default if there is no matching icon 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 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:

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

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) function:

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

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
richardhundt/shine: A Shiny Lua Dialect发布时间:2022-08-16
下一篇:
RedisLabs/geo.lua: A helper library for Redis geospatial indices发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap