π£ nerdfix helps you to find/fix obsolete Nerd Font icons in your project
Rust
474
178 commits
updated Nov 23, 2024
nerdfix helps you to find/fix obsolete Nerd Font icons in your project.
Nerd Fonts is used in many projects for a beautiful UI. It provides more than 10,000 icons, but some codepoints conflict
with other fonts (especially CJK fonts). To ensure that the icons remain in the private use area, Nerd Fonts has changed
the codepoints of some icons in recent releases, for example, mdi-* icons (including over 2,000 icons) are deprecated
since v2.3.3 and will be removed in v3.
These icons are marked as obsolete in the official cheat sheet and it's
recommended to replace them with the new ones. However, you may find it boring to check all the used icons one by one,
so nerdfix was written to index the cheat sheet and find obsolete icons in your project.
You can download the pre-built binaries from the release page or manually build this project manually from source.
In addition, the binaries come with a recently updated cheat sheet and you can overwrite it with the latest one using
nerdfix -i /path/to/your/file (follow
this link to get the
latest file).
You can build and install from the source code with cargo:
cargo install --git https://github.com/loichyan/nerdfix.git
Or with nix:
nix run github:loichyan/nerdfix
Please make sure you're using Nerd Fonts after v2.3.3, otherwise the replaced new icons may not be displayed correctly. If you are a plugin author, it's also recommended to notify this in updates.
The check command checks input files and reports obsolete icons with some suggestions (sorted by similarity) that you
could replace them with.
nerdfix check test/test-data.txt
You get the output as follows:
warning: Found obsolete icon U+F752
ββ tests/test-data.txt:1:27
β
1 β mdi-folder_multiple = "ο"
β ^ Icon 'mdi-folder_multiple' is marked as obsolete
β
= You could replace it with:
1. σ° U+F0253 md-folder_multiple
2. σ± U+F13D3 md-folder_star_multiple
...
The fix command reports the same information as check and displays a prompt asking the user to input a new icon to
replace the obsolete one.
warning: Found obsolete icon U+F719
ββ tests/test-data.txt:4:29
β
4 β mdi-file_document_box = "ο"
β ^ Icon 'mdi-file_document_box' is marked as obsolete
β
= You could replace it with:
1. σ° U+F0219 md-file_document
2. σ°· U+F0DC8 md-file_document_edit
...
> Input an icon: 1
# Your input: σ°
The prompt accepts several types of input:
| Type | Example |
|---|---|
| Suggestion number | 1 |
| Codepoint | U+F0219 |
| Icon name | md-file_document |
| Icon character | σ° |
The prompt also provides fuzzy matching suggestions when you type the icon name:
> Input an icon: documentmultiple
σ± md-file_document_multiple
σ± md-file_document_multiple_outline
σ°‘ md-comment_multiple
...
You can also use the search command to call the prompt directly for a fuzzy search.
nerdfix provides some features to automatically patch obsolete icons:
--sub FROM/TO (or --sub exact:FROM/TO for full syntax) to replace one icon with another, e.g. mdi-tab is
replaced with md-tab when --sub mdi-tab/md-tab is specified.--sub prefix:FROM/TO to replace the prefix of an icon name with another, e.g. mdi-tab is replaced with
md-tab when --sub prefix:mdi-/md- is specified.nerdfix accepts icons and substutitions in the following JSON format:
{
"icons": [
{ "name": "md-file_document", "codepoint": "f0219" },
{ "name": "mdi-file_document_box", "codepoint": "0f719", "obsolete": true }
],
"substitutions": ["exact:mdi-file_document_box/md-file_document"]
}
As mentioned above, the precompiled nerdfix binary comes bundled with an indexed database that includes all available
icons and some common substitutions.
You can use check --format json to get structured output for further use. nerdfix prints diagnostics with the
following fields line by line:
| Field | Description |
|---|---|
severity | Severity of a diagnostic |
path | Source file of a diagnostic |
type | Diagnostic type, currently only obsolete is supported |
span | Byte index span of an obsolete icon |
name | Icon name |
codepoint | Icon codepoint |
nerdfix check --format=json -r /path/to/root 2>/dev/null |
jq -s -r '[.[].path] | sort | unique | .[]'
nerdfix fix /path/to/input:/path/to/output
nerdfix fix --recursive /path/to/root
# Or use fd/find
nerdfix fix $(fd -t f . /path/to/root)
nerdfix fix --write --select-first /path/to/file
Licensed under either of
at your option.
178 commits
Rust
90.7%
Just
4.4%
Nix
3.2%
jq
1.3%
π£ nerdfix helps you to find/fix obsolete Nerd Font icons in your project
Rust
474
178 commits
updated Nov 23, 2024
nerdfix helps you to find/fix obsolete Nerd Font icons in your project.
Nerd Fonts is used in many projects for a beautiful UI. It provides more than 10,000 icons, but some codepoints conflict
with other fonts (especially CJK fonts). To ensure that the icons remain in the private use area, Nerd Fonts has changed
the codepoints of some icons in recent releases, for example, mdi-* icons (including over 2,000 icons) are deprecated
since v2.3.3 and will be removed in v3.
These icons are marked as obsolete in the official cheat sheet and it's
recommended to replace them with the new ones. However, you may find it boring to check all the used icons one by one,
so nerdfix was written to index the cheat sheet and find obsolete icons in your project.
You can download the pre-built binaries from the release page or manually build this project manually from source.
In addition, the binaries come with a recently updated cheat sheet and you can overwrite it with the latest one using
nerdfix -i /path/to/your/file (follow
this link to get the
latest file).
You can build and install from the source code with cargo:
cargo install --git https://github.com/loichyan/nerdfix.git
Or with nix:
nix run github:loichyan/nerdfix
Please make sure you're using Nerd Fonts after v2.3.3, otherwise the replaced new icons may not be displayed correctly. If you are a plugin author, it's also recommended to notify this in updates.
The check command checks input files and reports obsolete icons with some suggestions (sorted by similarity) that you
could replace them with.
nerdfix check test/test-data.txt
You get the output as follows:
warning: Found obsolete icon U+F752
ββ tests/test-data.txt:1:27
β
1 β mdi-folder_multiple = "ο"
β ^ Icon 'mdi-folder_multiple' is marked as obsolete
β
= You could replace it with:
1. σ° U+F0253 md-folder_multiple
2. σ± U+F13D3 md-folder_star_multiple
...
The fix command reports the same information as check and displays a prompt asking the user to input a new icon to
replace the obsolete one.
warning: Found obsolete icon U+F719
ββ tests/test-data.txt:4:29
β
4 β mdi-file_document_box = "ο"
β ^ Icon 'mdi-file_document_box' is marked as obsolete
β
= You could replace it with:
1. σ° U+F0219 md-file_document
2. σ°· U+F0DC8 md-file_document_edit
...
> Input an icon: 1
# Your input: σ°
The prompt accepts several types of input:
| Type | Example |
|---|---|
| Suggestion number | 1 |
| Codepoint | U+F0219 |
| Icon name | md-file_document |
| Icon character | σ° |
The prompt also provides fuzzy matching suggestions when you type the icon name:
> Input an icon: documentmultiple
σ± md-file_document_multiple
σ± md-file_document_multiple_outline
σ°‘ md-comment_multiple
...
You can also use the search command to call the prompt directly for a fuzzy search.
nerdfix provides some features to automatically patch obsolete icons:
--sub FROM/TO (or --sub exact:FROM/TO for full syntax) to replace one icon with another, e.g. mdi-tab is
replaced with md-tab when --sub mdi-tab/md-tab is specified.--sub prefix:FROM/TO to replace the prefix of an icon name with another, e.g. mdi-tab is replaced with
md-tab when --sub prefix:mdi-/md- is specified.nerdfix accepts icons and substutitions in the following JSON format:
{
"icons": [
{ "name": "md-file_document", "codepoint": "f0219" },
{ "name": "mdi-file_document_box", "codepoint": "0f719", "obsolete": true }
],
"substitutions": ["exact:mdi-file_document_box/md-file_document"]
}
As mentioned above, the precompiled nerdfix binary comes bundled with an indexed database that includes all available
icons and some common substitutions.
You can use check --format json to get structured output for further use. nerdfix prints diagnostics with the
following fields line by line:
| Field | Description |
|---|---|
severity | Severity of a diagnostic |
path | Source file of a diagnostic |
type | Diagnostic type, currently only obsolete is supported |
span | Byte index span of an obsolete icon |
name | Icon name |
codepoint | Icon codepoint |
nerdfix check --format=json -r /path/to/root 2>/dev/null |
jq -s -r '[.[].path] | sort | unique | .[]'
nerdfix fix /path/to/input:/path/to/output
nerdfix fix --recursive /path/to/root
# Or use fd/find
nerdfix fix $(fd -t f . /path/to/root)
nerdfix fix --write --select-first /path/to/file
Licensed under either of
at your option.
178 commits
Rust
90.7%
Just
4.4%
Nix
3.2%
jq
1.3%