Skip to content

Commit 4b0d255

Browse files
gegounealex-courtishasecilu
authored
refactor: split tables into individual files (#550)
Co-authored-by: Alexander Courtis <[email protected]> Co-authored-by: hasecilu <[email protected]>
1 parent 4567e0d commit 4b0d255

24 files changed

+1849
-1845
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lua/nvim-web-devicons/light/* linguist-generated=true

.luacheckrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ read_globals = {
1010
"MiniAlign",
1111
}
1212

13-
files["lua/nvim-web-devicons/icons-*.lua"].max_line_length = 200
13+
files["lua/nvim-web-devicons/*/icons_*.lua"].max_line_length = 200

.styluaignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lua/nvim-web-devicons/icons-*.lua
1+
lua/nvim-web-devicons/*/icons_*.lua

CONTRIBUTING.md

Lines changed: 37 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
Thank you for your contribution!
44

5-
## Order
6-
7-
Please ensure `icons_by_filename`, `icons_by_file_extension`, `icons_by_operating_system`, `icons_by_desktop_environment`,
8-
`icons_by_window_manager` and `filetypes` are ordered alphabetically, to prevent merge conflicts.
9-
105
## Prerequisites
116

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

22+
## Adding icons
23+
24+
Add or update icons in `lua/nvim-web-devicons/default/` directory
25+
26+
There are five files where icons can be added:
27+
28+
1. `icons_by_filename.lua`
29+
2. `icons_by_file_extension.lua`
30+
3. `icons_by_operating_system.lua`
31+
4. `icons_by_desktop_environment.lua`
32+
5. `icons_by_window_manager.lua`
33+
34+
Add the icon to table in file **1.** if the icon is for a file that is always named that way, for example `.gitconfig`.
35+
Add the icon to table in file **2.** if the icon is for all files with an extension, for example `vim`.
36+
Add the icon to table in files **3.**, **4.** and **5.** if the icon is from an OS, DE or WM.
37+
38+
Each icon must have the following structure (this is an example):
39+
40+
```lua
41+
[".gitconfig"] = { icon = "", color = "#41535b", cterm_color = "0", name = "GitConfig" },
42+
```
43+
44+
> [!IMPORTANT]
45+
> Make sure each icon association occupies exactly one line.
46+
47+
***All of the following keys are required:***
48+
49+
- `icon` glyph
50+
- `color` must contain a color in the html notation
51+
- `cterm_color` must contain a number (any number)
52+
- the correct value for `cterm_color` will be generated by the script in next step
53+
- `name` must only contain alphanumeric characters (don't use `/`, `-`, `_`)
54+
2755
## Building
2856

57+
Note: Ensure your current working directory is the repo root.
58+
2959
Following your changes, please run:
3060

3161
```sh
@@ -34,7 +64,7 @@ make
3464

3565
This will:
3666

37-
1. `git clone --depth 1 https://github.com/lifepillar/vim-colortemplate.git vim-colortemplate` if necessary
67+
1. Install required plugins: [vim-colortemplate](https://github.com/lifepillar/vim-colortemplate.git) and [mini.align](https://github.com/echasnovski/mini.align) if necessary
3868
2. Generate cterm colors
3969
3. Generate light color variants
4070
4. Check style
@@ -47,46 +77,7 @@ You can automatically fix any style issues via:
4777
make style-fix
4878
```
4979

50-
## Generate Colors
51-
52-
Add or update icons in `lua/nvim-web-devicons/icons-default.lua`
53-
54-
There are five tables where icons can be added:
55-
56-
1. `icons_by_filename`
57-
2. `icons_by_file_extension`
58-
3. `icons_by_operating_system`
59-
4. `icons_by_desktop_environment`
60-
5. `icons_by_window_manager`
61-
62-
Add the icon to table **1.** if the icon is for a file that is always named that way, for example `.gitconfig`.
63-
Add the icon to table **2.** if the icon is for all files with an extension, for example `vim`.
64-
Add the icon to table **3.**, **4.**, **5.** if the icon is from an OS, DE or WM.
65-
66-
Each icon must have the following structure (this is an example):
67-
68-
```lua
69-
[".gitconfig"] = {
70-
icon = "",
71-
color = "#41535b",
72-
cterm_color = "0",
73-
name = "GitConfig",
74-
},
75-
```
76-
77-
***Key/value pairs must appear in the same exact order!***
78-
79-
- `color` must contain a color in the html notation
80-
- `cterm_color` must be below `color`, and it must contain a number (any number)
81-
- the correct value for `cterm_color` will be generated by the script
82-
- `name` must only contain alphanumeric characters (don't use `/`, `-`, `_`)
83-
84-
Ensure your current working directory is the repo root. Run `make`. This will:
85-
86-
- Update `cterm_color` based on `color`
87-
- Generate `lua/nvim-web-devicons/icons-light.lua`
88-
89-
Please commit both `lua/nvim-web-devicons/icons-default.lua` and `lua/nvim-web-devicons/icons-light.lua`
80+
Please commit all files from `lua/nvim-web-devicons/default/`, `lua/nvim-web-devicons/light/` end `lua/nvim-web-devicons/filetypes.lua`
9081

9182
## Test
9283

Makefile

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
VIM_COLORTEMPLATE_VERSION = 2.2.3
22
VIM_MINI_ALIGN_VERSION = 0.14.0
33

4-
all: colors style-check lint filetypes
4+
all: generate style-check lint filetypes
55

6-
colors: vim-colortemplate mini-align
7-
rm lua/nvim-web-devicons/icons-light.lua
8-
cp lua/nvim-web-devicons/icons-default.lua lua/nvim-web-devicons/icons-light.lua
6+
generate: vim-colortemplate mini-align
7+
rm -f lua/nvim-web-devicons/light/icons_by_*.lua
8+
cp lua/nvim-web-devicons/default/icons_by_*.lua lua/nvim-web-devicons/light/
99
nvim \
1010
--clean \
1111
--headless \
1212
--cmd "set rtp^=vim-colortemplate" \
1313
--cmd "set rtp^=mini-align" \
14-
-c 'source scripts/generate_colors.lua' \
15-
-c 'source scripts/align_spaces.lua' \
14+
-c 'source scripts/generate.lua' \
15+
-c 'source scripts/align.lua' \
16+
-c 'source scripts/sort_filetypes.lua' \
1617
-c 'qall'
1718

18-
colors-check: colors
19-
git diff --exit-code lua/nvim-web-devicons/icons-default.lua
20-
git diff --exit-code lua/nvim-web-devicons/icons-light.lua
19+
colors-check: generate
20+
git diff --exit-code lua/nvim-web-devicons/default/
21+
git diff --exit-code lua/nvim-web-devicons/light/
22+
git diff --exit-code lua/nvim-web-devicons/filetypes.lua
2123

2224
vim-colortemplate:
2325
mkdir -p vim-colortemplate
@@ -43,4 +45,4 @@ clean:
4345
rm -rf vim-colortemplate
4446
rm -rf mini-align
4547

46-
.PHONY: all colors style-check style-fix lint filetypes
48+
.PHONY: all clean generate colors-check style-check style-fix lint filetypes

0 commit comments

Comments
 (0)