Skip to content

Commit c5e49f5

Browse files
committed
docs: improve instructions and apply style
1 parent ec5fa0f commit c5e49f5

File tree

2 files changed

+78
-50
lines changed

2 files changed

+78
-50
lines changed

CONTRIBUTING.md

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ Thank you for your contribution!
44

55
## Order
66

7-
Please ensure `icons_by_filename`, `icons_by_file_extension` and `filetypes` are ordered alphabetically, to prevent merge conflicts.
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.
89

910
## Prerequisites
1011

11-
Code is formatted using stylua and linted using luacheck.
12+
Code is formatted using *stylua* and linted using *luacheck*.
1213

1314
You can install these with:
15+
1416
```sh
1517
cargo install stylua
1618
luarocks install luacheck
1719
```
1820

19-
or via your OS package manager e.g. Arch linux:
21+
or via your OS package manager e.g. *Arch Linux*:
22+
2023
```sh
21-
pacman -S stylua
22-
pacman -S luacheck
24+
pacman -S stylua luacheck
2325
```
2426

2527
## Building
@@ -31,13 +33,16 @@ make
3133
```
3234

3335
This will:
36+
3437
1. `git clone --depth 1 https://github.com/lifepillar/vim-colortemplate.git vim-colortemplate` if necessary
35-
1. Generate cterm colors
36-
2. Generate light color variants
37-
3. Check style
38-
4. Lint
38+
2. Generate cterm colors
39+
3. Generate light color variants
40+
4. Check style
41+
5. Lint
42+
6. Find missing filetypes
3943

4044
You can automatically fix any style issues via:
45+
4146
```sh
4247
make style-fix
4348
```
@@ -46,15 +51,20 @@ make style-fix
4651

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

49-
There are two tables where icons can be added:
50-
1. icons_by_filename
51-
2. icons_by_file_extension
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.
5265

53-
Add the icon in table 1. if the icon is for a file that is always named that
54-
way, for example `.gitconfig`. Add to table 2. if the icon is for all files
55-
with an extension.
66+
Each icon must have the following structure (this is an example):
5667

57-
Each icon must have the following (this is an example):
5868
```lua
5969
[".gitconfig"] = {
6070
icon = "",
@@ -63,15 +73,16 @@ Each icon must have the following (this is an example):
6373
name = "GitConfig",
6474
},
6575
```
66-
___Key/value pairs must appear in the same exact order!___
76+
77+
***Key/value pairs must appear in the same exact order!***
6778

6879
- `color` must contain a color in the html notation
6980
- `cterm_color` must be below `color`, and it must contain a number (any number)
7081
- the correct value for `cterm_color` will be generated by the script
7182
- `name` must only contain alphanumeric characters (don't use `/`, `-`, `_`)
7283

73-
Ensure your current working directory is the repo root.
74-
Run `make`. This will:
84+
Ensure your current working directory is the repo root. Run `make`. This will:
85+
7586
- Update `cterm_color` based on `color`
7687
- Generate `lua/nvim-web-devicons/icons-light.lua`
7788

@@ -81,44 +92,47 @@ Please commit both `lua/nvim-web-devicons/icons-default.lua` and `lua/nvim-web-d
8192

8293
Run `:NvimWebDeviconsHiTest` to view the icons and their highlighting.
8394

84-
Start neovim with `TERM=xterm-256color nvim ...` to test cterm.
95+
Start *Neovim* with `TERM=xterm-256color nvim ...` to test cterm.
8596

8697
Check with `&background` `dark` and `light`
8798

8899
## Documentation
89100

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

92-
# Pull Request
103+
## Pull Request
93104

94105
Please reference any issues in the description e.g. "resolves #1234", which will be closed upon merge.
95106

96-
Please check "allow edits by maintainers" to allow nvim-web-devicons maintainers to make small changes such as documentation tweaks.
107+
Please check "allow edits by maintainers" to allow *nvim-web-devicons* maintainers to make small changes
108+
such as documentation tweaks.
97109

98110
## Subject
99111

100112
The merge commit message will be the subject of the PR.
101113

102-
A [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) subject will be validated by the Semantic Pull Request Subject CI job. Reference the issue to be used in the release notes e.g.
114+
A [Conventional Commits] subject will be validated by the Semantic Pull Request Subject CI job.
115+
Reference the issue to be used in the release notes e.g.
103116

104-
```
117+
```txt
105118
feat: add gradle icons
106119
fix: update rust icon
107120
feat(#192): :NvimWebDeviconsHiTest
108121
```
109122

110123
Available types:
111-
* feat: A new feature
112-
* fix: A bug fix
113-
* docs: Documentation only changes
114-
* style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
115-
* refactor: A code change that neither fixes a bug nor adds a feature
116-
* perf: A code change that improves performance
117-
* test: Adding missing tests or correcting existing tests
118-
* build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
119-
* ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
120-
* chore: Other changes that don't modify src or test files
121-
* revert: Reverts a previous commit
124+
125+
- feat: A new feature
126+
- fix: A bug fix
127+
- docs: Documentation only changes
128+
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
129+
- refactor: A code change that neither fixes a bug nor adds a feature
130+
- perf: A code change that improves performance
131+
- test: Adding missing tests or correcting existing tests
132+
- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
133+
- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
134+
- chore: Other changes that don't modify src or test files
135+
- revert: Reverts a previous commit
122136

123137
If in doubt, look at previous commits.
124138

@@ -130,7 +144,9 @@ It is useful to see the actual glyphs in the pull request. That can be done by s
130144

131145
Using firefox:
132146

133-
* Settings -> General
134-
* Fonts -> Advanced
135-
* Change Monospace to "Hack Nerd Font Mono" or similar
136-
* Uncheck "Allow pages to choose their own fonts, instead of your selections above"
147+
- Settings -> General
148+
- Fonts -> Advanced
149+
- Change Monospace to "Hack Nerd Font Mono" or similar
150+
- Uncheck "Allow pages to choose their own fonts, instead of your selections above"
151+
152+
[Conventional Commits]: <https://www.conventionalcommits.org/en/v1.0.0>

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
# Notice
2-
Nerd fonts moved some symbols with version 3.0. Version 2.3 is meant for transition, supporting both version 2 and version 3 icons.
3-
4-
Nvim-web-devicons requires version 2.3 or above to work properly. If you are unable to update please use your plugin manager to pin version of nvim-web-dev icons to `nerd-v2-compat` tag.
5-
61
# Nvim-web-devicons
72

8-
Provides [Nerd Font](https://www.nerdfonts.com/) <sup>[1]</sup> icons (glyphs) for use by neovim plugins:
3+
Provides [Nerd Font](https://www.nerdfonts.com/) [^1] icons (glyphs) for use by *Neovim* plugins:
4+
95
- Icons by:
106
- Extension
117
- Full name
@@ -15,7 +11,13 @@ Provides [Nerd Font](https://www.nerdfonts.com/) <sup>[1]</sup> icons (glyphs) f
1511

1612
A `lua` fork of [vim-devicons](https://github.com/ryanoasis/vim-devicons).
1713

18-
<sup>[1]</sup> Not limited to Nerd Font icons: unicode and other fonts may be used.
14+
> [!IMPORTANT]
15+
> Nerd fonts moved some symbols with version 3.0. Version 2.3 is meant for transition,
16+
> supporting both version 2 and version 3 icons.
17+
> Nvim-web-devicons requires version 2.3 or above to work properly. If you are unable to update
18+
> please use your plugin manager to pin version of nvim-web-dev icons to `nerd-v2-compat` tag.
19+
20+
[^1]: Not limited to Nerd Font icons: unicode and other fonts may be used.
1921

2022
## Requirements
2123

@@ -30,10 +32,16 @@ Plug 'nvim-tree/nvim-web-devicons'
3032

3133
or with [packer.nvim](https://github.com/wbthomason/packer.nvim)
3234

33-
```
35+
```lua
3436
use 'nvim-tree/nvim-web-devicons'
3537
```
3638

39+
or with [lazy.nvim](https://github.com/folke/lazy.nvim)
40+
41+
```lua
42+
{ "nvim-tree/nvim-web-devicons", opts = {} },
43+
```
44+
3745
[![LuaRocks](https://img.shields.io/luarocks/v/nvim-tree/nvim-web-devicons?logo=lua&color=purple)](https://luarocks.org/modules/nvim-tree/nvim-web-devicons)
3846

3947
## Usage
@@ -48,6 +56,7 @@ Light or dark color variants of the icons depend on `&background`.
4856
The variant can also be set manually in `setup` with the `variant` option.
4957

5058
The variant is updated:
59+
5160
- on `OptionSet` event for `background`, or
5261
- after explicitly calling `require("nvim-web-devicons").refresh()`.
5362

@@ -68,7 +77,7 @@ if the color scheme changes
6877

6978
```lua
7079
require'nvim-web-devicons'.setup {
71-
-- your personnal icons can go here (to override)
80+
-- your personal icons can go here (to override)
7281
-- you can specify color or cterm_color instead of specifying both of them
7382
-- DevIcon will be appended to `name`
7483
override = {
@@ -126,7 +135,7 @@ require'nvim-web-devicons'.setup {
126135

127136
### Get Icon
128137

129-
Get the icon for a given file by passing in the `name`, the `extension` and an _optional_ options `table`.
138+
Get the icon for a given file by passing in the `name`, the `extension` and an *optional* options `table`.
130139
The name is passed in to check for an exact match e.g. `.bashrc` if there is no exact name match the extension
131140
is used. Calls `.setup()` if it hasn't already ran.
132141

@@ -146,6 +155,7 @@ require'nvim-web-devicons'.get_icon(filename, extension, { default = true })
146155
```
147156

148157
You can check if the setup function was already called with:
158+
149159
```lua
150160
require'nvim-web-devicons'.has_loaded()
151161
```
@@ -156,6 +166,7 @@ require'nvim-web-devicons'.has_loaded()
156166
`get_icon_cterm_color` returns cterm color instead of gui color
157167
`get_icon` returns icon and highlight name.
158168
If you want to get color code, you can use this function.
169+
159170
```lua
160171
local icon, color = require'nvim-web-devicons'.get_icon_color("init.lua", "lua")
161172
assert(icon == "")
@@ -220,7 +231,8 @@ or set the icon to use for a filetype with:
220231
require("nvim-web-devicons").set_icon_by_filetype { cpp = "c", pandoc = "md", }
221232
```
222233

223-
These functions are the same as their counterparts without the `_by_filetype` suffix, but they take a filetype instead of a name/extension.
234+
These functions are the same as their counterparts without the `_by_filetype` suffix,
235+
but they take a filetype instead of a name/extension.
224236

225237
You can also use `get_icon_name_by_filetype(filetype)` to get the icon name associated with the filetype.
226238

0 commit comments

Comments
 (0)