Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/lua/nvim-web-devicons/filetypes.lua linguist-generated
/lua/nvim-web-devicons/icons-default.lua linguist-generated
/lua/nvim-web-devicons/icons-light.lua linguist-generated
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: "0.19"
args: --check lua scripts
args: --check .

colors:
runs-on: ubuntu-latest
Expand All @@ -51,4 +51,3 @@ jobs:

- name: make colors-check
run: make colors-check

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.lua
.luarocks
/nerd-fonts/
/vim-colortemplate/
3 changes: 3 additions & 0 deletions .styluaignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lua/nvim-web-devicons/filetypes.lua
lua/nvim-web-devicons/icons-light.lua
lua/nvim-web-devicons/icons-default.lua
85 changes: 34 additions & 51 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@

Thank you for your contribution!

## Name

Please name your commits and the PR simply e.g.

add .tex
update makefile icon
update .kt colors

## Order

Please ensure `icons_by_filename`, `icons_by_file_extension` and `filetypes` are ordered alphabetically, to prevent merge conflicts.

## Prerequisites

Code is formatted using stylua and linted using luacheck.
Expand All @@ -30,6 +18,23 @@ pacman -S stylua
pacman -S luacheck
```

## Adding / Updating icons

All datas of icons are defined in `lua/nvim-web-devicons/_gen/icons.lua`.

This file returns a table with keys and values.
The keys are strings that are used as part of the highlight name.
The values are tables that contain the following fields:

- **color** (`string`): color for the dark theme in RGB hex code
- **icon** (`string`): icon
- **extension** (optional, `string[]`): file extensions (e.g. `lua`, `py`)
- **file** (optional, `string[]`): file names (e.g. `dockerfile`, `.gitignore`)
- **filetype** (optional, `string[]`): filetypes (e.g. `text`, `checkhealth`)
- **os** (optional, `string[]`): OS name (e.g. `apple`, `nixos`)

Please ensure icons are ordered alphabetically by key, to prevent merge conflicts.

## Building

Following your changes, please run:
Expand All @@ -40,8 +45,10 @@ make

This will:
1. `git clone --depth 1 https://github.com/lifepillar/vim-colortemplate.git vim-colortemplate` if necessary
1. Generate cterm colors
2. Generate light color variants
2. Generate following files
- `lua/nvim-web-devicons/filetypes.lua`
- `lua/nvim-web-devicons/icons-default.lua`
- `lua/nvim-web-devicons/icons-light.lua`
3. Check style
4. Lint

Expand All @@ -50,54 +57,30 @@ You can automatically fix any style issues via:
make style-fix
```

## Generate Colors

Add or update icons in `lua/nvim-web-devicons/icons-default.lua`
## Testing

There are two tables where icons can be added:
1. icons_by_filename
2. icons_by_file_extension

Add the icon in table 1. if the icon is for a file that is always named that
way, for example `.gitconfig`. Add to table 2. if the icon is for all files
with an extension.

Each icon must have the following (this is an example):
```lua
[".gitconfig"] = {
icon = "",
color = "#41535b",
cterm_color = "0",
name = "GitConfig",
},
```
___Key/value pairs must appear in the same exact order!___
Run `:NvimWebDeviconsHiTest` to view the icons and their highlighting.

- `color` must contain a color in the html notation
- `cterm_color` must be below `color`, and it must contain a number (any number)
- the correct value for `cterm_color` will be generated by the script
Start neovim with `TERM=xterm-256color nvim ...` to test cterm.

Ensure your current working directory is the repo root.
Run `make`. This will:
- Update `cterm_color` based on `color`
- Generate `lua/nvim-web-devicons/icons-light.lua`
Check with `&background` `dark` and `light`

Please commit both `lua/nvim-web-devicons/icons-default.lua` and `lua/nvim-web-devicons/icons-light.lua`
## Documentation

## Test
When modifying or adding API, please update [Usage](README.md#Usage)

Run `:NvimWebDeviconsHiTest` to view the icons and their highlighting.
## Commit

Start neovim with `TERM=xterm-256color nvim ...` to test cterm.
Please name your commits and the PR simply e.g.

Check with `&background` `dark` and `light`
```
add .tex
update makefile icon
update .kt colors
```

## Pull Request

Please reference any issues in the description e.g. "resolves #1234".

Please check "allow edits by maintainers" to allow nvim-web-devicons maintainers to make small changes such as documentation tweaks.

## Documentation

When modifying or adding API, please update [Usage](README.md#Usage)
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
NERD_FONTS_VERSION = 3.1.1
VIM_COLORTEMPLATE_VERSION = 2.2.3

all: colors style-check lint

colors: vim-colortemplate
colors: nerd-fonts vim-colortemplate
nvim \
--clean \
--headless \
--cmd "set rtp^=vim-colortemplate" \
-c 'source scripts/generate_colors.lua' \
-c 'qall'
--cmd "set rtp^=." \
-l "lua/nvim-web-devicons/_gen/init.lua"

colors-check: colors
git diff --exit-code lua/nvim-web-devicons/filetypes.lua
git diff --exit-code lua/nvim-web-devicons/icons-default.lua
git diff --exit-code lua/nvim-web-devicons/icons-light.lua

vim-colortemplate:
mkdir -p vim-colortemplate
curl -L https://github.com/lifepillar/vim-colortemplate/archive/refs/tags/v$(VIM_COLORTEMPLATE_VERSION).tar.gz | tar zx --directory vim-colortemplate --strip-components=1
git clone --depth 1 -b v$(VIM_COLORTEMPLATE_VERSION) https://github.com/lifepillar/vim-colortemplate.git vim-colortemplate

nerd-fonts:
git clone --depth 1 --filter blob:none --sparse -b v$(NERD_FONTS_VERSION) https://github.com/ryanoasis/nerd-fonts.git nerd-fonts

style-check:
stylua . --check
Expand All @@ -24,9 +29,9 @@ style-fix:
stylua .

lint:
luacheck lua scripts
luacheck lua

clean:
rm -rf vim-colortemplate
rm -rf nerd-fonts vim-colortemplate

.PHONY: all colors style-check style-fix lint
Loading