Giter VIP home page Giter VIP logo

nerdfix's Introduction

๐Ÿ”ฃ nerdfix

GitHub Release GitHub Workflow Status

nerdfix helps you to find/fix obsolete Nerd Font icons in your project.

๐Ÿ’ญ Why

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.

โš™๏ธ Installation

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).

Install from source

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

๐Ÿ“‹ Note

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.

๐Ÿ” Usage

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
        ...

Interactive patching

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 ๓ฐˆ™

Fuzzy autocompletion/search

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.

Autofix

nerdfix provides some features to automatically patch obsolete icons:

  • The last user input is picked if an icon appears twice.
  • Use --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.
  • Use --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.

Database

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.

Structured output

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

๐Ÿ’ฌ FAQ

How can I find all files that contain obsolete icons?

nerdfix check --format=json -r /path/to/root 2>/dev/null |
  jq -s -r '[.[].path] | sort | unique | .[]'

How can I save patched content to a file other than the input? (#7)

nerdfix fix /path/to/input:/path/to/output

How can I recursively traverse all directories? (#5)

nerdfix fix --recursive /path/to/root
# Or use fd/find
nerdfix fix $(fd -t f . /path/to/root)

How can I skip interactive prompts? (#3)

nerdfix fix --write --select-first /path/to/file

โš–๏ธ License

Licensed under either of

at your option.

nerdfix's People

Contributors

loichyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nerdfix's Issues

0.3.0 tests fail

Hello,

The tests fails with the latest release:

$ cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.05s
     Running unittests src/main.rs (target/debug/deps/nerdfix-f43ad6ff20021f57)

running 3 tests
test icon::tests::icon_from_str ... ok
test icon::tests::icon_to_str ... ok
test parser::tests::parser ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/cli.rs (target/debug/deps/cli-69cee76f507f960a)

running 3 tests
test check_with_input ... ok
test check_json ... ok
test check ... FAILED

failures:

---- check stdout ----
thread 'check' panicked at 'Unexpected stdout, failed fn(var)

command=`"/home/sanpi/projects/arch/nerdfix/src/nerdfix-0.3.0/target/debug/nerdfix" "check" "tests/test-data.txt"`
code=0
stdout=<84 lines total>
```
\u{1b}[0m\u{1b}[1m\u{1b}[38;5;10mnote\u{1b}[0m\u{1b}[1m: Found obsolete icon U+F752\u{1b}[0m
  \u{1b}[0m\u{1b}[34mโ”Œโ”€\u{1b}[0m tests/test-data.txt:1:27
  \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
\u{1b}[0m\u{1b}[34m1\u{1b}[0m \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m nf-mdi-folder_multiple = \"\u{1b}[0m\u{1b}[32m\u{f752}\u{1b}[0m\"
  \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m                           \u{1b}[0m\u{1b}[32m^\u{1b}[0m \u{1b}[0m\u{1b}[32mIcon \'nf-mdi-folder_multiple\' is marked as obsolete\u{1b}[0m
  \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
  \u{1b}[0m\u{1b}[34m=\u{1b}[0m You could replace it with:
        1. \u{f0253} U+F0253 nf-md-folder_multiple
        2. \u{f13d3} U+F13D3 nf-md-folder_star_multiple
        3. \u{f0254} U+F0254 nf-md-folder_multiple_image
        4. \u{f147e} U+F147E nf-md-folder_multiple_plus

\u{1b}[0m\u{1b}[1m\u{1b}[38;5;10mnote\u{1b}[0m\u{1b}[1m: Found obsolete icon U+F719\u{1b}[0m
  \u{1b}[0m\u{1b}[34mโ”Œโ”€\u{1b}[0m tests/test-data.txt:4:29
  \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
\u{1b}[0m\u{1b}[34m4\u{1b}[0m \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m nf-mdi-file_document_box = \"\u{1b}[0m\u{1b}[32m\u{f719}\u{1b}[0m\"
  \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m                             \u{1b}[0m\u{1b}[32m^\u{1b}[0m \u{1b}[0m\u{1b}[32mIcon \'nf-mdi-file_document_box\' is marked as obsolete\u{1b}[0m
  \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
  \u{1b}[0m\u{1b}[34m=\u{1b}[0m You could replace it with:
        1. \u{f0219} U+F0219 nf-md-file_document
```
<24 lines omitted>
```
         2. \u{e65d} U+E65D nf-seti-git
         3. \u{f1d3} U+F1D3 nf-fa-git
         4. \u{e702} U+E702 nf-dev-git

\u{1b}[0m\u{1b}[1m\u{1b}[38;5;10mnote\u{1b}[0m\u{1b}[1m: Found obsolete icon U+F9E8\u{1b}[0m
   \u{1b}[0m\u{1b}[34mโ”Œโ”€\u{1b}[0m tests/test-data.txt:14:15
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
\u{1b}[0m\u{1b}[34m14\u{1b}[0m \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m nf-mdi-tab = \"\u{1b}[0m\u{1b}[32m๏งจ\u{1b}[0m\"
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m               \u{1b}[0m\u{1b}[32m^^\u{1b}[0m \u{1b}[0m\u{1b}[32mIcon \'nf-mdi-tab\' is marked as obsolete\u{1b}[0m
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
   \u{1b}[0m\u{1b}[34m=\u{1b}[0m You could replace it with:
         1. \u{f04e9} U+F04E9 nf-md-tab
         2. \u{f523} U+F523 nf-oct-tab
         3. \u{f04eb} U+F04EB nf-md-table
         4. \u{f0ba0} U+F0BA0 nf-md-gitlab

\u{1b}[0m\u{1b}[1m\u{1b}[38;5;10mnote\u{1b}[0m\u{1b}[1m: Found obsolete icon U+FC0A\u{1b}[0m
   \u{1b}[0m\u{1b}[34mโ”Œโ”€\u{1b}[0m tests/test-data.txt:17:27
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
\u{1b}[0m\u{1b}[34m17\u{1b}[0m \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m nf-mdi-rhombus_outline = \"\u{1b}[0m\u{1b}[32m๏ฐŠ\u{1b}[0m\"
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m                           \u{1b}[0m\u{1b}[32m^\u{1b}[0m \u{1b}[0m\u{1b}[32mIcon \'nf-mdi-rhombus_outline\' is marked as obsolete\u{1b}[0m
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
   \u{1b}[0m\u{1b}[34m=\u{1b}[0m You could replace it with:
         1. \u{f070c} U+F070C nf-md-rhombus_outline
         2. \u{f0ba6} U+F0BA6 nf-md-help_rhombus_outline
         3. \u{f11cf} U+F11CF nf-md-alert_rhombus_outline
         4. \u{f14dd} U+F14DD nf-md-rhombus_split_outline

\u{1b}[0m\u{1b}[1m\u{1b}[38;5;10mnote\u{1b}[0m\u{1b}[1m: Found obsolete icon U+F554\u{1b}[0m
   \u{1b}[0m\u{1b}[34mโ”Œโ”€\u{1b}[0m tests/test-data.txt:20:29
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
\u{1b}[0m\u{1b}[34m20\u{1b}[0m \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m nf-mdi-arrow_right_thick = \"\u{1b}[0m\u{1b}[32m\u{f554}\u{1b}[0m\"
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m                             \u{1b}[0m\u{1b}[32m^\u{1b}[0m \u{1b}[0m\u{1b}[32mIcon \'nf-mdi-arrow_right_thick\' is marked as obsolete\u{1b}[0m
   \u{1b}[0m\u{1b}[34mโ”‚\u{1b}[0m
   \u{1b}[0m\u{1b}[34m=\u{1b}[0m You could replace it with:
         1. \u{f0055} U+F0055 nf-md-arrow_right_thick
         2. \u{f09c6} U+F09C6 nf-md-arrow_top_right_thick
         3. \u{f19b0} U+F19B0 nf-md-arrow_right_thin
         4. \u{f09ba} U+F09BA nf-md-arrow_bottom_right_thick

```

stderr=""
', /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:250:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    check

test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.37s

error: test failed, to rerun pass `--test cli`

Autofix yes flag does not seem to be working

Hi,

I'm using

$ nerdfix --version
nerdfix 0.2.3
cheat-sheet: 634e151

To autofix a file containing icons at /tmp/all2 by running nerdfix fix -y /tmp/all2 but it seems to prompt me interactively no matter what I try.

no report output

Thank you for the package!

I'm using nerdfix on my popos linux system. I believe I am running it correctly and it appears to run correct (see message below) however it doesn't generate a report at all.

I am using:

nerdfix 0.3.1
cheat-sheet: b5bf856

What am I missing?

 nerdfix check -r R

Running the above generates the below output

 INFO nerdfix::runtime: Check input file 'R/utils-pipe.R'
 INFO nerdfix::runtime: Check input file 'R/contoso_dim_date.R'
 INFO nerdfix::runtime: Check input file 'R/contoso_dim_product.R'
 INFO nerdfix::runtime: Check input file 'R/contoso_dim_promotion.R'
 INFO nerdfix::runtime: Check input file R/contoso_dim_product_subcategory.R'
 INFO nerdfix::runtime: Check input file 'R/divide.R'
 INFO nerdfix::runtime: Check input file 'R/totalytd.R'
 INFO nerdfix::runtime: Check input file 'R/contoso_fact_sales.R'
 INFO nerdfix::runtime: Check input file 'R/contoso_dim_channel.R'
 INFO nerdfix::runtime: Check input file 'R/new_vs_returning.R'
 INFO nerdfix::runtime: Check input file 'R/abc.R'
 INFO nerdfix::runtime: Check input file 'R/count_plus.R'
 INFO nerdfix::runtime: Check input file 'R/show_in_excel.R'
 INFO nerdfix::runtime: Check input file 'R/time_intelligence.R'
 INFO nerdfix::runtime: Check input file 'R/datasets.R'
 INFO nerdfix::runtime: Check input file 'R/abc_graph.R'
 INFO nerdfix::runtime: Check input file 'R/calculate.R'
 INFO nerdfix::runtime: Check input file 'R/clean_file_names.R'
 INFO nerdfix::runtime: Check input file 'R/make_segmentation.R'

but then I'm returned to my command prompt without any additional outputs

Thoughts?

Add support for checking folders

Thanks for this useful project! What do you think about adding support for folders when using the nerdfix check / nerdfix fix commands in which case the command would be applied to all the files in the directory recursively? This would allow something like nerdfix check ~/.local/share/nvim to check all Nvim configuration files.

Suggest replacement for F719

First of all I want to say thank you for this great tool! ๐Ÿฅ‡
This really helps Nerd Fonts to help others with the painful transition to the new codepoints.
I would add you as contributor to Nerd Font, if you agree.

On this Issue topic:
Via Gitter I just had the question where F719 is. This is what nerdfix says:

image

The direct replacement for F719 (file_document_box) is F021A (text_box).
(They renamed the icon.)

I do not know if nerdfix has the possibility to handle pairs that have not-similar names, so maybe this is not possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.