Skip to content

Commit

Permalink
update contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis committed Mar 17, 2024
1 parent 1ba5bb9 commit 67cd3c1
Showing 1 changed file with 51 additions and 33 deletions.
84 changes: 51 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# TODO #192 update following CI configuration

# Contributing to `nvim-web-devicons`

Thank you for your contribution!
Expand All @@ -8,30 +6,43 @@ Thank you for your contribution!

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.
feat: add tex
fix: makefile icon
fix: update kt colors

## Prerequisites

Code is formatted using stylua and linted using luacheck.
### Style And Lint

You can install these with:
```sh
cargo install stylua
luarocks install luacheck
luarocks --local install luacheck
```

or via your OS package manager e.g. Arch linux:
or
```sh
pacman -S stylua
pacman -S luacheck
```

### Building

Generating icon lua code:
```sh
luarocks --local install inspect
```
or
```sh
yay -S lua-inspect
```

### Optional

[yq](https://github.com/mikefarah/yq) for updating nerd-fonts `glyphnames.lua`

```sh
pacman -S go-yq
```

## Building

Following your changes, please run:
Expand All @@ -41,11 +52,12 @@ make
```

This will:
1. Generate `lua/nvim-web-devicons/icons-*.lua`
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
3. Check style
4. Lint
1. Generate light color variants
1. Check style
1. Lint

You can automatically fix any style issues via:
```sh
Expand All @@ -54,37 +66,43 @@ make style-fix

## Generate Colors

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

There are two tables where icons can be added:
1. icons_by_filename
2. icons_by_file_extension
Add or update icons in `src/by-*.lua`

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.
There are three tables in which icons can be added:
1. name: the icon is for a file that is always named that way, for example `.gitconfig`
1. ext: the icon is for all files with that extension
1. os: icon for an os or variant

Each icon must have the following (this is an example):

```lua
[".gitconfig"] = {
icon = "",
class = "seti-config",
color = "#41535b",
cterm_color = "0",
name = "GitConfig",
},
```
___Key/value pairs must appear in the same exact order!___

- `class` must be a vailid nerd-font class, see [cheat sheet](https://www.nerdfonts.com/cheat-sheet)
- `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

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`
- Generate `lua/nvim-web-devicons/icons-*.lua` with an `icon` and `cterm_color`
- Generate `lua/nvim-web-devicons/icons-light.lua` from the above, with light `color` and `cterm_color`

Example generated icon:
```lua
[".gitconfig"] = {
class = "seti-config",
color = "#41535b",
cterm_color = "239",
icon = "",
name = "GitConfig"
},
```

Please commit both `lua/nvim-web-devicons/icons-default.lua` and `lua/nvim-web-devicons/icons-light.lua`
Please commit `src/by-*.lua`, `lua/nvim-web-devicons/icons-default.lua` and `lua/nvim-web-devicons/icons-light.lua`

## Test

Expand Down

0 comments on commit 67cd3c1

Please sign in to comment.