2024-06-19 13:59:45 +08:00
|
|
|
local Docs = require("lazy.docs")
|
|
|
|
local Util = require("lazy.util")
|
|
|
|
|
2024-06-19 05:17:53 +08:00
|
|
|
local M = {}
|
|
|
|
|
2024-06-19 13:59:45 +08:00
|
|
|
---@param path string
|
|
|
|
local function dir(path)
|
2024-06-23 16:09:41 +08:00
|
|
|
local plugin, extra = path:match("([^/]+)(.*)")
|
|
|
|
return require("lazy.core.config").plugins[plugin].dir .. extra
|
2024-06-19 13:59:45 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
M.extract = {
|
2024-06-23 16:09:41 +08:00
|
|
|
["configuration/index"] = {
|
|
|
|
config = Docs.extract(dir("lazy.nvim/lua/lazy/core/config.lua"), "\nM%.defaults = ({.-\n})")
|
|
|
|
:gsub("%s*debug = false.\n", "\n"),
|
|
|
|
},
|
|
|
|
["configuration/highlights"] = {
|
|
|
|
colors = Docs.colors({
|
|
|
|
path = dir("lazy.nvim/lua/lazy/view/colors.lua"),
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
["spec/examples"] = {
|
|
|
|
examples = Util.read_file(dir("lazy.nvim/lua/lazy/example.lua")),
|
|
|
|
},
|
|
|
|
["usage/index"] = {
|
|
|
|
stats = Docs.extract(dir("lazy.nvim/lua/lazy/stats.lua"), "\nM%._stats = ({.-\n})"),
|
|
|
|
commands = Docs.commands(),
|
|
|
|
},
|
2024-06-19 13:59:45 +08:00
|
|
|
}
|
|
|
|
|
2024-06-19 05:17:53 +08:00
|
|
|
local function exec(cmd)
|
2024-06-23 16:09:41 +08:00
|
|
|
return vim.system(vim.split(cmd, " "), { text = true }):wait()
|
2024-06-19 05:17:53 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.themes()
|
2024-06-23 16:09:41 +08:00
|
|
|
exec("rm -rf src/themes")
|
|
|
|
exec("mkdir -p src/themes")
|
|
|
|
exec("cp -r .nvim/plugins/tokyonight.nvim/extras/prism src/themes/prism")
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.installation()
|
|
|
|
local install = Util.read_file("lua/tpl/install.lua")
|
|
|
|
local install_multi = install:gsub(
|
|
|
|
"spec = {}",
|
|
|
|
[[spec = {
|
|
|
|
-- import your plugins
|
|
|
|
{ import = "plugins" },
|
|
|
|
}]]
|
|
|
|
)
|
|
|
|
local install_single = install:gsub(
|
|
|
|
"spec = {}",
|
|
|
|
[[spec = {
|
|
|
|
-- add your plugins here
|
|
|
|
}]]
|
|
|
|
)
|
|
|
|
return {
|
|
|
|
install_single = {
|
|
|
|
content = install_single,
|
|
|
|
lang = 'lua title="~/.config/nvim/init.lua"',
|
|
|
|
},
|
|
|
|
install_multi = {
|
|
|
|
content = install_multi,
|
|
|
|
lang = 'lua title="~/.config/nvim/lua/config/lazy.lua"',
|
|
|
|
},
|
|
|
|
}
|
2024-06-19 05:17:53 +08:00
|
|
|
end
|
|
|
|
|
2024-06-19 13:59:45 +08:00
|
|
|
function M.docs()
|
2024-06-23 16:09:41 +08:00
|
|
|
M.extract.installation = M.installation()
|
|
|
|
for name, data in pairs(M.extract) do
|
|
|
|
local md = "docs/" .. name .. ".md"
|
|
|
|
if vim.uv.fs_stat(md .. "x") then
|
|
|
|
md = md .. "x"
|
|
|
|
end
|
|
|
|
print("Building " .. md)
|
|
|
|
Docs.save(data, md)
|
|
|
|
end
|
2024-06-19 13:59:45 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function M._old()
|
2024-06-23 16:09:41 +08:00
|
|
|
M.save({
|
|
|
|
stats = M.extract("lua/lazy/stats.lua", "\nM%._stats = ({.-\n})"),
|
|
|
|
commands = M.commands(),
|
|
|
|
})
|
2024-06-19 13:59:45 +08:00
|
|
|
end
|
|
|
|
|
2024-06-19 05:17:53 +08:00
|
|
|
function M.update()
|
2024-06-23 16:09:41 +08:00
|
|
|
M.themes()
|
|
|
|
M.docs()
|
2024-06-19 05:17:53 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|