nvim-tree / nvim-web-devicons

lua `fork` of vim-web-devicons for neovim
MIT License
1.98k stars 183 forks source link

fix: update to Nerd Fonts 3 code points #264

Closed vlada-dudr closed 1 year ago

vlada-dudr commented 1 year ago

Nerd Fonts 3 changed code points of some icons, this updates it according to table here

This will break everyone being on Nerd 2, but without it everyone on version 3 is broken also...

fixes #265

Flygrounder commented 1 year ago

I believe, the proper way of handling this is by adding an option in setup. I am not sure though, what should be the default: old version or new as probably most users have not yet upgraded to v3.

eeeXun commented 1 year ago

Some obsoleted icons didn't change. nerdfix may help.

carlosala commented 1 year ago

I agree with @Flygrounder, it should be a flag. I'm personally using nf3, but most of the people will be for sure stuck for years in v2.

luizkowalski commented 1 year ago

just weighing in: according to the Finii from Nerd Font, there should be a "translation" database (under details). I'm not sure if these would be backwards compatible to be honest. Does anyone know?

carlosala commented 1 year ago

@luizkowalski I'd say there are icons (the ones https://www.nerdfonts.com/cheat-sheet) that are not marked as obsolete and are compatible for both versions.

Finii commented 1 year ago

there are icons [...] that are not marked as obsolete and are compatible for both versions

In my opinion it would always be better to not-use the Material Design Icons (also not the new ones), because they do not have a codepoint-stability guarantee, so with the next update the icon on codepoint X could be exchanged :roll_eyes: It does not happen often, but from time to time if you really compare their releases. Maybe by accident. On the other hand, MDI has so many icons and if you want some very specific one there is only MDI that has it.

I think there is a document about the codepoint stability of the various sets: https://github.com/ryanoasis/nerd-fonts/issues/365#issuecomment-1254969225. As project I would prefer icons where upstream guarantees that their codepoints will not change.

carlosala commented 1 year ago

@Finii the problem is what you pointed out. MD added now 7k icons, that are probably quite unique and not replaceable. Codepoints defined in NF are the standard nowadays, I'd stick to them and I don't think they are going to change in the short term (we have been for a lot of years with the same ones)

Finii commented 1 year ago

:+1: And I always check (and try to fix if needed) codepoint stability on any upstream update (see for example the octicons update where Nerd Fonts introduces a codepoint stability where there was none upstream).

vlada-dudr commented 1 year ago

@luizkowalski: that's what I used to convert.

I was thinking to wrap translation table into lua, but it seemed wasteful to include table of ~1600 entries.

I am curious how implement two sets of icons. I see options: 1) embedding translation table and when icon is requested do translation 2) adding extra field into icon definitions for second icon option 3) make second set of whole icon definition

I am in favour of 3) - easy to drop, easy to generate through translation table from original table in make script.

rootex- commented 1 year ago

Some obsoleted icons didn't change. nerdfix may help.

thanks, nerdfix did help 🤝

luizkowalski commented 1 year ago

Some obsoleted icons didn't change. nerdfix may help.

thanks, nerdfix did help 🤝

@rootex- mind to share how you did it? I tried nerdfix but it is not working for some reason...

mehalter commented 1 year ago

It's also worth noting that the new locations of the material design icons (nf-md-X) are also available in Nerd Fonts v2 with v2.3+. The breaking change that came with v3 simply removed the old locations that were going to be deprecated. So migrating these icons (nf-mdi-X to nf-md-X) will maintain compatibility with the latest v2 and v3. Granted this will not support <v2.3, so I would agree that having a flag for legacy support would be a good idea but keeping the default as using the new v3 icon locations.

mehalter commented 1 year ago

You could also just add a comment on the README with the last commit that supported Nerd Fonts v2 which people can use it if they don't want to install (or can't install) Nerd Fonts v3 for whatever reason. It just depends on if you want to continuously maintain support for v2 as new features get added to nvim-web-devicons.

rootex- commented 1 year ago

@luizkowalski

Some obsoleted icons didn't change. nerdfix may help.

thanks, nerdfix did help 🤝

@rootex- mind to share how you did it? I tried nerdfix but it is not working for some reason...

To discover all obsolete symbols in a file:

$ nerdfix check <filename>
note: Found obsolete icon U+F722
  ┌─ filename:1:9
  │
1 │ icon = "",
  │         ^ Icon 'nf-mdi-file_music' is marked as obsolete
  │
  = You could replace it with:
        1. 󰈣 U+F0223 nf-md-file_music
        2. 󰝚 U+F075A nf-md-music
        3. 󰸪 U+F0E2A nf-md-file_music_outline
        4. 󱝟 U+F175F nf-md-archive_music
...
...
...

To fix every obsolete symbol, input a number or search symbols with autocompletion:

$ nerdfix fix <filename>
// prints a prompt for every symbol
note: Found obsolete icon U+F722
  ┌─ filename:1:9
  │
1 │ icon = "",
  │         ^ Icon 'nf-mdi-file_music' is marked as obsolete
  │
  = You could replace it with:
        1. 󰈣 U+F0223 nf-md-file_music
        2. 󰝚 U+F075A nf-md-music
        3. 󰸪 U+F0E2A nf-md-file_music_outline
        4. 󱝟 U+F175F nf-md-archive_music

? Input an icon:
  1
  2
  3
  4
[(Tab) to autocomplete, (Esc) to cancel, (Ctrl-C) to abort]
vlada-dudr commented 1 year ago

Thinking about it more, maybe it is ok to merge it. Nerd fonts released version 2.3 earlier this year and deprecated now dropped code points. There are two solutions for people on <=2.2: install newer version (easy), pin commit (easy). Let's just make sure people know what's going on.

vlada-dudr commented 1 year ago

I updated readme and reworded commit so it contains exclamation mark

mehalter commented 1 year ago

Thinking about it more, maybe it is ok to merge it. Nerd fonts released version 2.3 earlier this year and deprecated now dropped code points. There are two solutions for people on <=2.2: install newer version (easy), pin commit (easy). Let's just make sure people know what's going on.

I think this is a good approach, one comment I would make is it might be a good idea to include the commit hash in the notice of the last commit that supports Nerd Fonts <= 2.2 for people who want to just pin their commit.

carlosala commented 1 year ago

Totally agree

vlada-dudr commented 1 year ago

Or maybe let's tag (or branch?) that commit so it is more explicit?

tapayne88 commented 1 year ago

Apologies for interrupting your conversation but I think this PR might be missing some icons. When I've run nerdfix locally I've found the following also need updating

Could just be my version of nerdfont and/or nerdfix though! 😅

vlada-dudr commented 1 year ago

@tapayne88 you can pull request my master if you wish ;)

tapayne88 commented 1 year ago

@tapayne88 you can pull request my master if you wish ;)

Hopefully this should do it - https://github.com/vlada-dudr/nvim-web-devicons/pull/1 🤞

vlada-dudr commented 1 year ago

@tapayne88, so I merged it into my branch.

Now tell me who can move it forward...

gegoune commented 1 year ago

I'll try to review tomorrow.

Thanks to everyone involved!

gegoune commented 1 year ago

I have just pushed aforementioned compat tag pointing to current master.

redyf commented 1 year ago

@luizkowalski

Some obsoleted icons didn't change. nerdfix may help.

thanks, nerdfix did help handshake

@rootex- mind to share how you did it? I tried nerdfix but it is not working for some reason...

To discover all obsolete symbols in a file:

$ nerdfix check <filename>
note: Found obsolete icon U+F722
  ┌─ filename:1:9
  │
1 │ icon = "",
  │         ^ Icon 'nf-mdi-file_music' is marked as obsolete
  │
  = You could replace it with:
        1. 󰈣 U+F0223 nf-md-file_music
        2. 󰝚 U+F075A nf-md-music
        3. 󰸪 U+F0E2A nf-md-file_music_outline
        4. 󱝟 U+F175F nf-md-archive_music
...
...
...

To fix every obsolete symbol, input a number or search symbols with autocompletion:

$ nerdfix fix <filename>
// prints a prompt for every symbol
note: Found obsolete icon U+F722
  ┌─ filename:1:9
  │
1 │ icon = "",
  │         ^ Icon 'nf-mdi-file_music' is marked as obsolete
  │
  = You could replace it with:
        1. 󰈣 U+F0223 nf-md-file_music
        2. 󰝚 U+F075A nf-md-music
        3. 󰸪 U+F0E2A nf-md-file_music_outline
        4. 󱝟 U+F175F nf-md-archive_music

? Input an icon:
  1
  2
  3
  4
[(Tab) to autocomplete, (Esc) to cancel, (Ctrl-C) to abort]

This was really helpful, thanks!