2022-09-05 14:17:10 +00:00
|
|
|
local M = {}
|
2021-04-20 12:24:44 +00:00
|
|
|
|
2023-04-22 08:30:43 +00:00
|
|
|
-- map of plugin name to plugin extension
|
|
|
|
--- @type table<string, {ext:string, url:string, label:string}>
|
|
|
|
-- stylua: ignore
|
|
|
|
M.extras = {
|
|
|
|
kitty = {ext = "conf", url = "https://sw.kovidgoyal.net/kitty/conf.html", label = "Kitty"},
|
|
|
|
fish = {ext = "fish", url = "https://fishshell.com/docs/current/index.html", label = "Fish"},
|
|
|
|
fish_themes = {ext = "theme", url = "https://fishshell.com/docs/current/interactive.html#syntax-highlighting", label = "Fish Themes"},
|
|
|
|
alacritty = {ext = "yml", url = "https://github.com/alacritty/alacritty", label = "Alacritty"},
|
|
|
|
wezterm = {ext = "toml", url = "https://wezfurlong.org/wezterm/config/", label = "WezTerm"},
|
|
|
|
tmux = {ext = "tmux", url = "https://github.com/tmux/tmux/wiki", label = "Tmux"},
|
|
|
|
xresources = {ext = "Xresources", url = "https://wiki.archlinux.org/title/X_resources", label = "Xresources"},
|
|
|
|
xfceterm = {ext = "theme", url = "https://docs.xfce.org/apps/terminal/advanced", label = "Xfce Terminal"},
|
|
|
|
foot = {ext = "ini", url = "https://codeberg.org/dnkl/foot", label = "Foot"},
|
|
|
|
tilix = {ext = "json", url = "https://github.com/gnunn1/tilix", label = "Tilix"},
|
|
|
|
iterm = {ext = "itermcolors", url = "https://iterm2.com/", label = "iTerm"},
|
|
|
|
lua = {ext = "lua", url = "https://www.lua.org", label = "Lua Table for testing"},
|
|
|
|
sublime = {ext = "tmTheme", url = "https://www.sublimetext.com/docs/themes", label = "Sublime Text"},
|
|
|
|
delta = {ext = "gitconfig", url = "https://github.com/dandavison/delta", label = "Delta"},
|
|
|
|
terminator = {ext = "conf", url = "https://gnome-terminator.readthedocs.io/en/latest/config.html", label = "Terminator"},
|
|
|
|
prism = {ext = "js", url = "https://prismjs.com", label = "Prism"},
|
|
|
|
windows_terminal = {ext = "json", url = "https://aka.ms/terminal-documentation", label = "Windows Terminal"},
|
|
|
|
}
|
|
|
|
|
2021-04-20 12:24:44 +00:00
|
|
|
local function write(str, fileName)
|
2022-09-05 10:06:20 +00:00
|
|
|
print("[write] extra/" .. fileName)
|
2022-09-18 21:51:39 +00:00
|
|
|
vim.fn.mkdir(vim.fs.dirname("extras/" .. fileName), "p")
|
2022-09-05 10:06:20 +00:00
|
|
|
local file = io.open("extras/" .. fileName, "w")
|
|
|
|
file:write(str)
|
|
|
|
file:close()
|
2021-04-20 12:24:44 +00:00
|
|
|
end
|
|
|
|
|
2023-04-22 08:30:43 +00:00
|
|
|
function M.read_file(file)
|
|
|
|
local fd = assert(io.open(file, "r"))
|
|
|
|
---@type string
|
|
|
|
local data = fd:read("*a")
|
|
|
|
fd:close()
|
|
|
|
return data
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.write_file(file, contents)
|
|
|
|
local fd = assert(io.open(file, "w+"))
|
|
|
|
fd:write(contents)
|
|
|
|
fd:close()
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.docs()
|
|
|
|
local file = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h:h:h:h") .. "/README.md"
|
|
|
|
local tag = "extras"
|
|
|
|
local pattern = "(<%!%-%- " .. tag .. ":start %-%->).*(<%!%-%- " .. tag .. ":end %-%->)"
|
|
|
|
local readme = M.read_file(file)
|
|
|
|
local lines = {}
|
|
|
|
local names = vim.tbl_keys(M.extras)
|
|
|
|
table.sort(names)
|
|
|
|
for _, name in ipairs(names) do
|
|
|
|
info = M.extras[name]
|
2023-04-23 09:05:40 +00:00
|
|
|
table.insert(lines, "- [" .. info.label .. "](" .. info.url .. ") ([" .. name .. "](extras/" .. name .. "))")
|
2023-04-22 08:30:43 +00:00
|
|
|
end
|
|
|
|
readme = readme:gsub(pattern, "%1\n" .. table.concat(lines, "\n") .. "\n%2")
|
|
|
|
M.write_file(file, readme)
|
|
|
|
end
|
|
|
|
|
2022-09-05 14:17:10 +00:00
|
|
|
function M.setup()
|
2023-04-22 08:30:43 +00:00
|
|
|
M.docs()
|
2022-09-05 14:17:10 +00:00
|
|
|
local config = require("tokyonight.config")
|
|
|
|
vim.o.background = "dark"
|
|
|
|
|
|
|
|
-- map of style to style name
|
|
|
|
local styles = {
|
|
|
|
storm = " Storm",
|
|
|
|
night = "",
|
|
|
|
day = " Day",
|
2022-09-18 21:46:44 +00:00
|
|
|
moon = " Moon",
|
2022-09-05 14:17:10 +00:00
|
|
|
}
|
2021-04-20 12:24:44 +00:00
|
|
|
|
2023-04-22 08:30:43 +00:00
|
|
|
for extra, info in pairs(M.extras) do
|
2023-01-18 14:06:08 +00:00
|
|
|
package.loaded["tokyonight.extra." .. extra] = nil
|
2022-09-05 14:17:10 +00:00
|
|
|
local plugin = require("tokyonight.extra." .. extra)
|
|
|
|
for style, style_name in pairs(styles) do
|
|
|
|
config.setup({ style = style })
|
|
|
|
local colors = require("tokyonight.colors").setup({ transform = true })
|
2023-04-22 08:30:43 +00:00
|
|
|
local fname = extra .. "/tokyonight_" .. style .. "." .. info.ext
|
2022-09-05 14:17:10 +00:00
|
|
|
colors["_upstream_url"] = "https://github.com/folke/tokyonight.nvim/raw/main/extras/" .. fname
|
|
|
|
colors["_style_name"] = "Tokyo Night" .. style_name
|
|
|
|
write(plugin.generate(colors), fname)
|
|
|
|
end
|
2022-09-05 10:06:20 +00:00
|
|
|
end
|
2021-05-21 12:51:45 +00:00
|
|
|
end
|
2022-09-05 14:17:10 +00:00
|
|
|
|
|
|
|
return M
|