fix(ci): luacats support

This commit is contained in:
Barrett Ruth 2026-02-23 17:25:57 -05:00
parent 747e7b6222
commit 6a8668fab5
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
6 changed files with 121 additions and 0 deletions

View file

@ -232,6 +232,16 @@ iTerm2 ~
Preferences > Profiles > Text > Non-ASCII Font > select Nonicons Preferences > Profiles > Text > Non-ASCII Font > select Nonicons
==============================================================================
COMMANDS *nonicons-commands*
*:NoniconsHiTest*
`:NoniconsHiTest`
Open a scratch buffer listing every icon in the nonicons font alongside
its name, Unicode codepoint, and which extensions / filenames / filetypes
map to it. Use this to visually verify that glyphs render correctly and
that resolution tables point to the intended icons.
============================================================================== ==============================================================================
HEALTH CHECK *nonicons-health* HEALTH CHECK *nonicons-health*

85
lua/nonicons/hi-test.lua Normal file
View file

@ -0,0 +1,85 @@
local mapping = require('nonicons.mapping')
local resolve = require('nonicons.resolve')
---@param name string
---@return string
local function char(name)
local code = mapping[name]
if code then
return vim.fn.nr2char(code)
end
return '?'
end
---@param t table<string, any>
---@return string[]
local function sorted_keys(t)
local keys = {}
for k in pairs(t) do
keys[#keys + 1] = k
end
table.sort(keys)
return keys
end
---@param t table<string, string>
---@return table<string, string[]>
local function invert(t)
local inv = {}
for k, v in pairs(t) do
inv[v] = inv[v] or {}
inv[v][#inv[v] + 1] = k
end
for _, list in pairs(inv) do
table.sort(list)
end
return inv
end
return function()
local lines = {} ---@type string[]
local ext_by_icon = invert(resolve.ext_map)
local fname_by_icon = invert(resolve.filename_map)
local ft_by_icon = invert(resolve.ft_map)
local icon_names = sorted_keys(mapping)
lines[#lines + 1] = 'nonicons.nvim — icon reference'
lines[#lines + 1] = string.rep('=', 72)
lines[#lines + 1] = ''
lines[#lines + 1] = string.format(' %-4s %-28s %-7s %s', 'ICON', 'NAME', 'CODE', 'MAPPED FROM')
lines[#lines + 1] = string.rep('-', 72)
for _, name in ipairs(icon_names) do
local sources = {} ---@type string[]
if ext_by_icon[name] then
for _, ext in ipairs(ext_by_icon[name]) do
sources[#sources + 1] = 'ext:' .. ext
end
end
if fname_by_icon[name] then
for _, fname in ipairs(fname_by_icon[name]) do
sources[#sources + 1] = 'file:' .. fname
end
end
if ft_by_icon[name] then
for _, ft in ipairs(ft_by_icon[name]) do
sources[#sources + 1] = 'ft:' .. ft
end
end
local src_str = #sources > 0 and table.concat(sources, ', ') or ''
lines[#lines + 1] = string.format(' %s %-28s U+%04X %s', char(name), name, mapping[name], src_str)
end
lines[#lines + 1] = ''
lines[#lines + 1] = string.format('%d icons total', #icon_names)
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
vim.bo[buf].modifiable = false
vim.bo[buf].buftype = 'nofile'
vim.bo[buf].bufhidden = 'wipe'
vim.api.nvim_set_current_buf(buf)
end

View file

@ -24,8 +24,11 @@ local function ensure_initialized()
initialized = true initialized = true
end end
---@type table<string, integer>
M.mapping = require('nonicons.mapping') M.mapping = require('nonicons.mapping')
---@param name string Icon name
---@return string? glyph
function M.get(name) function M.get(name)
local code = M.mapping[name] local code = M.mapping[name]
if code then if code then
@ -40,6 +43,9 @@ function M.apply()
end end
end end
---@param name string? Filename (e.g. `'init.lua'`)
---@param ext string? File extension (e.g. `'lua'`)
---@return string? glyph
function M.get_icon(name, ext) function M.get_icon(name, ext)
local key = require('nonicons.resolve').resolve_name(name, ext) local key = require('nonicons.resolve').resolve_name(name, ext)
if key then if key then
@ -47,6 +53,8 @@ function M.get_icon(name, ext)
end end
end end
---@param ft string Vim filetype
---@return string? glyph
function M.get_icon_by_filetype(ft) function M.get_icon_by_filetype(ft)
local key = require('nonicons.resolve').resolve_filetype(ft) local key = require('nonicons.resolve').resolve_filetype(ft)
if key then if key then

View file

@ -1,6 +1,8 @@
local mapping = require('nonicons.mapping') local mapping = require('nonicons.mapping')
local resolve_mod = require('nonicons.resolve') local resolve_mod = require('nonicons.resolve')
---@param name string
---@return string?
local function char(name) local function char(name)
local code = mapping[name] local code = mapping[name]
if code then if code then
@ -8,8 +10,12 @@ local function char(name)
end end
end end
---@type string
local fallback_icon local fallback_icon
---@param name string?
---@param ext string?
---@return string
local function resolve(name, ext) local function resolve(name, ext)
local key = resolve_mod.resolve_name(name, ext) local key = resolve_mod.resolve_name(name, ext)
if key then if key then

View file

@ -1,5 +1,6 @@
local M = {} local M = {}
---@type table<string, string>
M.ext_map = { M.ext_map = {
lua = 'lua', lua = 'lua',
luac = 'lua', luac = 'lua',
@ -287,6 +288,7 @@ M.ext_map = {
mojo = 'code', mojo = 'code',
} }
---@type table<string, string>
M.filename_map = { M.filename_map = {
['dockerfile'] = 'docker', ['dockerfile'] = 'docker',
['containerfile'] = 'docker', ['containerfile'] = 'docker',
@ -421,6 +423,7 @@ M.filename_map = {
['code_of_conduct.md'] = 'book', ['code_of_conduct.md'] = 'book',
} }
---@type table<string, string>
M.ft_map = { M.ft_map = {
typescriptreact = 'react', typescriptreact = 'react',
javascriptreact = 'react', javascriptreact = 'react',
@ -434,6 +437,9 @@ M.ft_map = {
latex = 'book', latex = 'book',
} }
---@param name string? Filename (e.g. `'init.lua'`)
---@param ext string? File extension (e.g. `'lua'`)
---@return string? icon_name
function M.resolve_name(name, ext) function M.resolve_name(name, ext)
if ext and M.ext_map[ext] then if ext and M.ext_map[ext] then
return M.ext_map[ext] return M.ext_map[ext]
@ -459,6 +465,8 @@ function M.resolve_name(name, ext)
end end
end end
---@param ft string? Vim filetype
---@return string? icon_name
function M.resolve_filetype(ft) function M.resolve_filetype(ft)
if not ft then if not ft then
return return

View file

@ -4,3 +4,7 @@ end
vim.g.loaded_nonicons = 1 vim.g.loaded_nonicons = 1
require('nonicons').apply() require('nonicons').apply()
vim.api.nvim_create_user_command('NoniconsHiTest', function()
require('nonicons.hi-test')()
end, { desc = 'nonicons: display all icons' })