nonicons.nvim/lua/nonicons/init.lua
Barrett Ruth 04791cd41a
feat: initial nonicons.nvim rewrite
Problem: the original ya2s/nvim-nonicons fork diverged enough that
maintaining it as a fork was pointless. The set_icon() approach broke
with modern nvim-web-devicons, and the extensions directory coupled
integrations that belong in user config.

Solution: from-scratch rewrite with function wrapping + table mutation
override engine, vim.g.nonicons config pattern, vendored mapping with
integer codepoints, health check, vimdoc with recipes, and no built-in
plugin integrations.
2026-02-17 19:34:13 -05:00

43 lines
781 B
Lua

local M = {}
---@class nonicons.Config
---@field override boolean
---@type nonicons.Config
local default = {
override = true,
}
local initialized = false
---@type nonicons.Config
local config
local function ensure_initialized()
if initialized then
return
end
local user = vim.g.nonicons or {}
vim.validate('nonicons', user, 'table')
vim.validate('nonicons.override', user.override, 'boolean', true)
config = vim.tbl_deep_extend('force', default, user)
initialized = true
end
M.mapping = require('nonicons.mapping')
function M.get(name)
local code = M.mapping[name]
if code then
return vim.fn.nr2char(code)
end
end
function M.apply()
ensure_initialized()
if config.override then
require('nonicons.override').apply()
end
end
return M