refactor(util): Remove dead color and highlight helpers

The light style is a hand-written palette rather than an inversion of the
dark one, so the invert helpers lost their last caller. They only ever
called each other, and the same is true of syntax and highlight. lighten
had no callers at all.

Removing highlight orphans treesitter.lua, whose only consumer was the
ts.get call inside it, so the module goes too. day_brightness fed nothing
but invert_color and was already a no-op, so drop the option and its docs.

Also fix the vimdoc palette example, which called the now-removed
util.lighten with colors.bg_dark and colors.red1 -- tokyonight names that
have never existed in this fork.

All 2822 highlight groups across the dark, light and vivid styles are
byte-for-byte identical before and after, and the extras rebuild clean.
This commit is contained in:
Takuya Matsuyama 2026-08-11 14:49:45 +09:00
parent d4695e455d
commit 6f3bcf9cd9
6 changed files with 2 additions and 460 deletions

View file

@ -92,7 +92,6 @@ require("solarized-osaka").setup({
floats = "dark", -- style for floating windows
},
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors
vivid_brightness = 0.3, -- Adjusts how far the **Vivid** style brightens text colors. Number between 0 and 1, from the default palette to white
hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.
dim_inactive = false, -- dims inactive windows

View file

@ -191,7 +191,6 @@ unless `setup` is explicitly called.
floats = "dark", -- style for floating windows
},
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
day_brightness = 0.3, -- Adjusts the brightness of the colors of the Day style. Number between 0 and 1, from dull to vibrant colors
hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard StatusLine and LuaLine.
dim_inactive = false, -- dims inactive windows
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold
@ -313,8 +312,8 @@ You can easily use the color palette for other plugins inside your Neovim
local colors = require("solarized-osaka.colors").setup() -- pass in any of the config options as explained above
local util = require("solarized-osaka.util")
aplugin.background = colors.bg_dark
aplugin.my_error = util.lighten(colors.red1, 0.3) -- number between 0 and 1. 0 results in white, 1 results in red1
aplugin.background = colors.bg
aplugin.my_error = util.darken(colors.red500, 0.3) -- number between 0 and 1. 0 results in the background color, 1 results in red500
<

View file

@ -232,7 +232,6 @@ function M.setup(opts)
local colors = vim.tbl_deep_extend("force", vim.deepcopy(M.default), palette)
util.bg = colors.bg
util.day_brightness = config.options.day_brightness
colors.black = util.darken(colors.bg, 0.8, "#000000")
colors.border = colors.black

View file

@ -20,7 +20,6 @@ local defaults = {
floats = "dark", -- style for floating windows
},
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors
vivid_brightness = 0.3, -- Adjusts how far the **Vivid** style brightens text colors. Number between 0 and 1, from the default palette to white
hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.
dim_inactive = false, -- dims inactive windows

View file

@ -1,380 +0,0 @@
local M = {}
function M.new_style()
---@diagnostic disable-next-line: undefined-field
return vim.treesitter.highlighter.hl_map == nil
end
function M.get(group)
if group:sub(1, 1) ~= "@" or M.new_style() then
return group
end
group = group:sub(2)
local lang
while group do
if M.fallbacks[group] then
return (lang or "") .. M.fallbacks[group]
end
group, lang = group:match("(.*)%.(.*)")
end
end
-- taken from https://github.com/nvim-treesitter/nvim-treesitter/blob/master/lua/nvim-treesitter/highlight.lua
M.fallbacks = {
["annotation"] = "TSAnnotation",
["attribute"] = "TSAttribute",
["boolean"] = "TSBoolean",
["character"] = "TSCharacter",
["character.special"] = "TSCharacterSpecial",
["comment"] = "TSComment",
["conditional"] = "TSConditional",
["constant"] = "TSConstant",
["constant.builtin"] = "TSConstBuiltin",
["constant.macro"] = "TSConstMacro",
["constructor"] = "TSConstructor",
["debug"] = "TSDebug",
["define"] = "TSDefine",
["error"] = "TSError",
["exception"] = "TSException",
["field"] = "TSField",
["float"] = "TSFloat",
["function"] = "TSFunction",
["function.call"] = "TSFunctionCall",
["function.builtin"] = "TSFuncBuiltin",
["function.macro"] = "TSFuncMacro",
["include"] = "TSInclude",
["keyword"] = "TSKeyword",
["keyword.function"] = "TSKeywordFunction",
["keyword.operator"] = "TSKeywordOperator",
["keyword.return"] = "TSKeywordReturn",
["label"] = "TSLabel",
["method"] = "TSMethod",
["method.call"] = "TSMethodCall",
["namespace"] = "TSNamespace",
["none"] = "TSNone",
["number"] = "TSNumber",
["operator"] = "TSOperator",
["parameter"] = "TSParameter",
["parameter.reference"] = "TSParameterReference",
["preproc"] = "TSPreProc",
["property"] = "TSProperty",
["punctuation.delimiter"] = "TSPunctDelimiter",
["punctuation.bracket"] = "TSPunctBracket",
["punctuation.special"] = "TSPunctSpecial",
["repeat"] = "TSRepeat",
["storageclass"] = "TSStorageClass",
["string"] = "TSString",
["string.regex"] = "TSStringRegex",
["string.escape"] = "TSStringEscape",
["string.special"] = "TSStringSpecial",
["symbol"] = "TSSymbol",
["tag"] = "TSTag",
["tag.attribute"] = "TSTagAttribute",
["tag.delimiter"] = "TSTagDelimiter",
["text"] = "TSText",
["text.strong"] = "TSStrong",
["text.emphasis"] = "TSEmphasis",
["text.underline"] = "TSUnderline",
["text.strike"] = "TSStrike",
["text.title"] = "TSTitle",
["text.literal"] = "TSLiteral",
["text.uri"] = "TSURI",
["text.math"] = "TSMath",
["text.reference"] = "TSTextReference",
["text.environment"] = "TSEnvironment",
["text.environment.name"] = "TSEnvironmentName",
["text.note"] = "TSNote",
["text.warning"] = "TSWarning",
["text.danger"] = "TSDanger",
["text.todo"] = "TSTodo",
["type"] = "TSType",
["type.builtin"] = "TSTypeBuiltin",
["type.qualifier"] = "TSTypeQualifier",
["type.definition"] = "TSTypeDefinition",
["variable"] = "TSVariable",
["variable.builtin"] = "TSVariableBuiltin",
}
M.defaults = {
["@annotation"] = {
default = true,
link = "PreProc",
},
["@attribute"] = {
default = true,
link = "PreProc",
},
["@boolean"] = {
default = true,
link = "Boolean",
},
["@character"] = {
default = true,
link = "Character",
},
["@character.special"] = {
default = true,
link = "SpecialChar",
},
["@comment"] = {
default = true,
link = "Comment",
},
["@conditional"] = {
default = true,
link = "Conditional",
},
["@constant"] = {
default = true,
link = "Constant",
},
["@constant.builtin"] = {
default = true,
link = "Special",
},
["@constant.macro"] = {
default = true,
link = "Define",
},
["@constructor"] = {
default = true,
link = "Special",
},
["@debug"] = {
default = true,
link = "Debug",
},
["@define"] = {
default = true,
link = "Define",
},
["@exception"] = {
default = true,
link = "Exception",
},
["@field"] = {
default = true,
link = "Identifier",
},
["@float"] = {
default = true,
link = "Float",
},
["@function"] = {
default = true,
link = "Function",
},
["@function.builtin"] = {
default = true,
link = "Special",
},
["@function.call"] = {
default = true,
link = "@function",
},
["@function.macro"] = {
default = true,
link = "Macro",
},
["@include"] = {
default = true,
link = "Include",
},
["@keyword"] = {
default = true,
link = "Keyword",
},
["@keyword.coroutine"] = {
default = true,
link = "@keyword",
},
["@keyword.function"] = {
default = true,
link = "Keyword",
},
["@keyword.operator"] = {
default = true,
link = "@operator",
},
["@keyword.return"] = {
default = true,
link = "@keyword",
},
["@label"] = {
default = true,
link = "Label",
},
["@method"] = {
default = true,
link = "Function",
},
["@method.call"] = {
default = true,
link = "@method",
},
["@namespace"] = {
default = true,
link = "Include",
},
["@none"] = {
default = true,
},
["@number"] = {
default = true,
link = "Number",
},
["@operator"] = {
default = true,
link = "Operator",
},
["@parameter"] = {
default = true,
link = "Identifier",
},
["@preproc"] = {
default = true,
link = "PreProc",
},
["@property"] = {
default = true,
link = "Identifier",
},
["@punctuation.bracket"] = {
default = true,
link = "Delimiter",
},
["@punctuation.delimiter"] = {
default = true,
link = "Delimiter",
},
["@punctuation.special"] = {
default = true,
link = "Delimiter",
},
["@repeat"] = {
default = true,
link = "Repeat",
},
["@storageclass"] = {
default = true,
link = "StorageClass",
},
["@string"] = {
default = true,
link = "String",
},
["@string.escape"] = {
default = true,
link = "SpecialChar",
},
["@string.regex"] = {
default = true,
link = "String",
},
["@string.special"] = {
default = true,
link = "SpecialChar",
},
["@symbol"] = {
default = true,
link = "Identifier",
},
["@tag"] = {
default = true,
link = "Label",
},
["@tag.attribute"] = {
default = true,
link = "@property",
},
["@tag.delimiter"] = {
default = true,
link = "Delimiter",
},
["@text"] = {
default = true,
link = "@none",
},
["@text.danger"] = {
default = true,
link = "WarningMsg",
},
["@text.emphasis"] = {
default = true,
italic = true,
},
["@text.environment"] = {
default = true,
link = "Macro",
},
["@text.environment.name"] = {
default = true,
link = "Type",
},
["@text.literal"] = {
default = true,
link = "String",
},
["@text.math"] = {
default = true,
link = "Special",
},
["@text.note"] = {
default = true,
link = "SpecialComment",
},
["@text.reference"] = {
default = true,
link = "Constant",
},
["@text.strike"] = {
strikethrough = true,
},
["@text.strong"] = {
bold = true,
default = true,
},
["@text.title"] = {
default = true,
link = "Title",
},
["@text.underline"] = {
underline = true,
},
["@text.uri"] = {
default = true,
link = "Underlined",
},
["@text.warning"] = {
default = true,
link = "Todo",
},
["@text.todo"] = {
default = true,
link = "Todo",
},
["@type"] = {
default = true,
link = "Type",
},
["@type.builtin"] = {
default = true,
link = "Type",
},
["@type.definition"] = {
default = true,
link = "Typedef",
},
["@type.qualifier"] = {
default = true,
link = "@keyword",
},
["@variable.builtin"] = {
default = true,
link = "Special",
},
}
return M

View file

@ -1,10 +1,6 @@
local ts = require("solarized-osaka.treesitter")
local M = {}
M.bg = "#000000"
M.fg = "#ffffff"
M.day_brightness = 0.3
---@param c string
local function hexToRgb(c)
@ -32,10 +28,6 @@ function M.darken(hex, amount, bg)
return M.blend(hex, bg or M.bg, amount)
end
function M.lighten(hex, amount, fg)
return M.blend(hex, fg or M.fg, amount)
end
--- Raises a color's perceptual lightness without draining its colorfulness.
---
---@param hex string
@ -65,39 +57,6 @@ function M.brighten(hex, amount)
return hsluv.rgb_to_hex(rgb)
end
function M.invert_color(color)
local hsluv = require("solarized-osaka.hsluv")
if color ~= "NONE" then
local hsl = hsluv.hex_to_hsluv(color)
hsl[3] = 100 - hsl[3]
if hsl[3] < 40 then
hsl[3] = hsl[3] + (100 - hsl[3]) * M.day_brightness
end
return hsluv.hsluv_to_hex(hsl)
end
return color
end
---@param group string
function M.highlight(group, hl)
group = ts.get(group)
if not group then
return
end
if hl.style then
if type(hl.style) == "table" then
hl = vim.tbl_extend("force", hl, hl.style)
elseif hl.style:lower() ~= "none" then
-- handle old string style definitions
for s in string.gmatch(hl.style, "([^,]+)") do
hl[s] = true
end
end
hl.style = nil
end
vim.api.nvim_set_hl(0, group, hl)
end
-- Simple string interpolation.
--
-- Example template: "${name} is ${value}"
@ -112,39 +71,6 @@ function M.template(str, table)
)
end
function M.syntax(syntax)
for group, colors in pairs(syntax) do
M.highlight(group, colors)
end
end
---@param colors ColorScheme
function M.invert_colors(colors)
if type(colors) == "string" then
---@diagnostic disable-next-line: return-type-mismatch
return M.invert_color(colors)
end
for key, value in pairs(colors) do
colors[key] = M.invert_colors(value)
end
return colors
end
---@param hls Highlights
function M.invert_highlights(hls)
for _, hl in pairs(hls) do
if hl.fg then
hl.fg = M.invert_color(hl.fg)
end
if hl.bg then
hl.bg = M.invert_color(hl.bg)
end
if hl.sp then
hl.sp = M.invert_color(hl.sp)
end
end
end
local me = debug.getinfo(1, "S").source:sub(2)
me = vim.fn.fnamemodify(me, ":h:h")