Skip to content

refactor: split tables into individual files #550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from 16 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lua/nvim-web-devicons/light/* linguist-generated=true
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ read_globals = {
"MiniAlign",
}

files["lua/nvim-web-devicons/icons-*.lua"].max_line_length = 200
files["lua/nvim-web-devicons/*/icons_*.lua"].max_line_length = 200
2 changes: 1 addition & 1 deletion .styluaignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lua/nvim-web-devicons/icons-*.lua
lua/nvim-web-devicons/*/icons_*.lua
83 changes: 37 additions & 46 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

Thank you for your contribution!

## Order

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

## Prerequisites

Code is formatted using *stylua* and linted using *luacheck*.
Expand All @@ -24,8 +19,43 @@ or via your OS package manager e.g. *Arch Linux*:
pacman -S stylua luacheck
```

## Adding icons
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I didn't just move the block here, so please review as new.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, reverted contributing changes on #551


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

There are five files where icons can be added:

1. `icons_by_filename.lua`
2. `icons_by_file_extension.lua`
3. `icons_by_operating_system.lua`
4. `icons_by_desktop_environment.lua`
5. `icons_by_window_manager.lua`

Add the icon to table in file **1.** if the icon is for a file that is always named that way, for example `.gitconfig`.
Add the icon to table in file **2.** if the icon is for all files with an extension, for example `vim`.
Add the icon to table in files **3.**, **4.** and **5.** if the icon is from an OS, DE or WM.

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

```lua
[".gitconfig"] = { icon = "", color = "#41535b", cterm_color = "0", name = "GitConfig" },
```

> [!IMPORTANT]
> Make sure an icon occupies exactly one line.

***All of the following keys are required:***

- `icon` glyph
- `color` must contain a color in the html notation
- `cterm_color` must contain a number (any number)
- the correct value for `cterm_color` will be generated by the script in next step
- `name` must only contain alphanumeric characters (don't use `/`, `-`, `_`)

## Building

Note: Ensure your current working directory is the repo root.

Following your changes, please run:

```sh
Expand All @@ -34,7 +64,7 @@ make

This will:

1. `git clone --depth 1 https://github.com/lifepillar/vim-colortemplate.git vim-colortemplate` if necessary
1. Install required plugins: [vim-colortemplate](https://github.com/lifepillar/vim-colortemplate.git) and [mini.align](https://github.com/echasnovski/mini.align) if necessary
2. Generate cterm colors
3. Generate light color variants
4. Check style
Expand All @@ -47,46 +77,7 @@ 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`

There are five tables where icons can be added:

1. `icons_by_filename`
2. `icons_by_file_extension`
3. `icons_by_operating_system`
4. `icons_by_desktop_environment`
5. `icons_by_window_manager`

Add the icon to table **1.** if the icon is for a file that is always named that way, for example `.gitconfig`.
Add the icon to table **2.** if the icon is for all files with an extension, for example `vim`.
Add the icon to table **3.**, **4.**, **5.** if the icon is from an OS, DE or WM.

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

```lua
[".gitconfig"] = {
icon = "",
color = "#41535b",
cterm_color = "0",
name = "GitConfig",
},
```

***Key/value pairs must appear in the same exact order!***

- `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
- `name` must only contain alphanumeric characters (don't use `/`, `-`, `_`)

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`

Please commit both `lua/nvim-web-devicons/icons-default.lua` and `lua/nvim-web-devicons/icons-light.lua`
Please commit all files from `lua/nvim-web-devicons/default/`, `lua/nvim-web-devicons/light/` end `lua/nvim-web-devicons/filetypes.lua`

## Test

Expand Down
22 changes: 12 additions & 10 deletions Makefile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all present in CI and work.

CI could be consolidated at some point but not today.

Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
VIM_COLORTEMPLATE_VERSION = 2.2.3
VIM_MINI_ALIGN_VERSION = 0.14.0

all: colors style-check lint filetypes
all: generate style-check lint filetypes

colors: vim-colortemplate mini-align
rm lua/nvim-web-devicons/icons-light.lua
cp lua/nvim-web-devicons/icons-default.lua lua/nvim-web-devicons/icons-light.lua
generate: vim-colortemplate mini-align
rm lua/nvim-web-devicons/light/icons_by_*.lua
cp lua/nvim-web-devicons/default/icons_by_*.lua lua/nvim-web-devicons/light/
nvim \
--clean \
--headless \
--cmd "set rtp^=vim-colortemplate" \
--cmd "set rtp^=mini-align" \
-c 'source scripts/generate_colors.lua' \
-c 'source scripts/align_spaces.lua' \
-c 'source scripts/generate.lua' \
-c 'source scripts/align.lua' \
-c 'source scripts/sort_filetypes.lua' \
-c 'qall'

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

vim-colortemplate:
mkdir -p vim-colortemplate
Expand All @@ -43,4 +45,4 @@ clean:
rm -rf vim-colortemplate
rm -rf mini-align

.PHONY: all colors style-check style-fix lint filetypes
.PHONY: all clean generate colors-check style-check style-fix lint filetypes
Loading
Loading