Last active
January 14, 2024 04:17
-
-
Save alex-courtis/26271d581e390fe26058bf0743539cc3 to your computer and use it in GitHub Desktop.
Map nvim-web-devicons To nerd-font
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local lunajson = require "lunajson" | |
local icons_by_filename = require("icons-default").icons_by_filename | |
local icons_by_file_extension = require("icons-default").icons_by_file_extension | |
local icons_by_operating_system = require("icons-default").icons_by_operating_system | |
-- read the json | |
local f, err, rc = io.open("glyphnames.json", "r") | |
if not f then | |
io.stderr:write(string.format("%s\n", err)) | |
os.exit(rc) | |
end | |
-- parse the json | |
local ok, glyphnames = pcall(lunajson.decode, f:read()) | |
f:close() | |
if not ok then | |
io.stderr:write(string.format("%s\n", glyphnames)) | |
os.exit(1) | |
end | |
---@cast glyphnames table | |
-- map name by codepoint value | |
local names_by_codepoint = {} | |
for name, data in pairs(glyphnames) do | |
if name and data and data.code then | |
local code = tonumber(data.code, 16) | |
if not names_by_codepoint[code] then | |
names_by_codepoint[code] = {} | |
end | |
table.insert(names_by_codepoint[code], name) | |
end | |
end | |
-- calculate codepoint for icons and output the name(s), codepoint, icon and web-devicons name | |
local function output(icons) | |
for name, data in pairs(icons) do | |
local cp = utf8.codepoint(data.icon) | |
local names = names_by_codepoint[cp] or { "NOGLYPH-" } | |
local i = 1 | |
for _, n in ipairs(names) do | |
print(string.format("%-25s %d/%d 0x%05x %s %-25s", n, i, #names, cp, data.icon, name)) | |
i = i + 1 | |
end | |
end | |
end | |
output(icons_by_filename) | |
output(icons_by_file_extension) | |
output(icons_by_operating_system) |
./lua audit.lua | sed -E 's/([^-]-).*/\1/g' | sort | uniq -c | sort -n
2 fae-
7 NOGLYPH-
8 cod-
13 oct-
27 custom-
31 linux-
32 fa-
58 md-
76 dev-
122 seti-
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./lua audit.lua | sort