mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 04:46:45 +00:00
docs: updated
This commit is contained in:
parent
ae4d912e16
commit
3d77e4514e
16 changed files with 565 additions and 268 deletions
103
lua/build.lua
103
lua/build.lua
|
@ -5,63 +5,88 @@ local M = {}
|
|||
|
||||
---@param path string
|
||||
local function dir(path)
|
||||
local plugin, extra = path:match("([^/]+)(.*)")
|
||||
return require("lazy.core.config").plugins[plugin].dir .. extra
|
||||
local plugin, extra = path:match("([^/]+)(.*)")
|
||||
return require("lazy.core.config").plugins[plugin].dir .. extra
|
||||
end
|
||||
|
||||
M.extract = {
|
||||
installation = {
|
||||
bootstrap = {
|
||||
lang = 'lua title="lua/config/lazy.lua"',
|
||||
content = Docs.extract(dir("lazy.nvim/lua/lazy/init.lua"), "function M%.bootstrap%(%)\n(.-)\nend"),
|
||||
},
|
||||
},
|
||||
["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(),
|
||||
},
|
||||
["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(),
|
||||
},
|
||||
}
|
||||
|
||||
local function exec(cmd)
|
||||
return vim.system(vim.split(cmd, " "), { text = true }):wait()
|
||||
return vim.system(vim.split(cmd, " "), { text = true }):wait()
|
||||
end
|
||||
|
||||
function M.themes()
|
||||
exec("rm -rf src/themes")
|
||||
exec("mkdir -p src/themes")
|
||||
exec("cp -r .nvim/plugins/tokyonight.nvim/extras/prism src/themes/prism")
|
||||
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"',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
function M.docs()
|
||||
for name, data in pairs(M.extract) do
|
||||
local md = "docs/" .. name .. ".md"
|
||||
print("Building " .. md)
|
||||
Docs.save(data, md)
|
||||
end
|
||||
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
|
||||
end
|
||||
|
||||
function M._old()
|
||||
M.save({
|
||||
stats = M.extract("lua/lazy/stats.lua", "\nM%._stats = ({.-\n})"),
|
||||
commands = M.commands(),
|
||||
})
|
||||
M.save({
|
||||
stats = M.extract("lua/lazy/stats.lua", "\nM%._stats = ({.-\n})"),
|
||||
commands = M.commands(),
|
||||
})
|
||||
end
|
||||
|
||||
function M.update()
|
||||
M.themes()
|
||||
M.docs()
|
||||
M.themes()
|
||||
M.docs()
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
62
lua/init.lua
62
lua/init.lua
|
@ -3,54 +3,54 @@ local root = vim.fn.fnamemodify("./.nvim", ":p")
|
|||
|
||||
-- set stdpaths to use .repro
|
||||
for _, name in ipairs({ "config", "data", "state", "cache" }) do
|
||||
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||
end
|
||||
|
||||
local lazy_dev = vim.fn.expand("~/projects/lazy.nvim")
|
||||
if vim.uv.fs_stat(lazy_dev) then
|
||||
vim.opt.runtimepath:prepend(lazy_dev)
|
||||
vim.opt.runtimepath:prepend(lazy_dev)
|
||||
else
|
||||
-- bootstrap lazy
|
||||
local lazypath = root .. "/plugins/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
print("Bootstrapping lazy.nvim")
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
-- bootstrap lazy
|
||||
local lazypath = root .. "/plugins/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
print("Bootstrapping lazy.nvim")
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
end
|
||||
|
||||
local function main()
|
||||
print("Installing plugins")
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
"folke/tokyonight.nvim",
|
||||
},
|
||||
root = root .. "/plugins",
|
||||
})
|
||||
print("Installing plugins")
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
"folke/tokyonight.nvim",
|
||||
},
|
||||
root = root .. "/plugins",
|
||||
})
|
||||
|
||||
if vim.o.filetype == "lazy" then
|
||||
vim.cmd.close()
|
||||
end
|
||||
if vim.o.filetype == "lazy" then
|
||||
vim.cmd.close()
|
||||
end
|
||||
|
||||
print("Updating plugins")
|
||||
-- update plugins, wait for it to finish and don't show the output
|
||||
require("lazy").update({ wait = true, show = false })
|
||||
-- require("lazy.core.cache").reset()
|
||||
print("Updating plugins")
|
||||
-- update plugins, wait for it to finish and don't show the output
|
||||
require("lazy").update({ wait = true, show = false })
|
||||
-- require("lazy.core.cache").reset()
|
||||
|
||||
vim.opt.rtp:append(".")
|
||||
vim.opt.rtp:append(".")
|
||||
|
||||
print("Building docs")
|
||||
print("Building docs")
|
||||
|
||||
require("build").update()
|
||||
require("build").update()
|
||||
|
||||
print("Done!\n")
|
||||
print("Done!\n")
|
||||
end
|
||||
|
||||
local Util = require("lazy.core.util")
|
||||
Util.try(main, {
|
||||
on_error = function(err)
|
||||
print(err)
|
||||
os.exit(1)
|
||||
end,
|
||||
on_error = function(err)
|
||||
print(err)
|
||||
os.exit(1)
|
||||
end,
|
||||
})
|
||||
os.exit(0)
|
||||
|
|
46
lua/tpl/install.lua
Normal file
46
lua/tpl/install.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- Make sure to setup `mapleader` before loading lazy.nvim
|
||||
-- This is also a good place to setup other settings (vim.opt)
|
||||
vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct
|
||||
vim.g.maplocalleader = "\\" -- Same for `maplocalleader`
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
-- highlight-start
|
||||
spec = {},
|
||||
-- highlight-end
|
||||
defaults = {
|
||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||
lazy = false,
|
||||
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||
-- have outdated releases, which may break your Neovim install.
|
||||
version = false, -- always use the latest git commit
|
||||
-- version = "*", -- try installing the latest stable version for plugins that support semver
|
||||
},
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
install = { colorscheme = { "habamax" } },
|
||||
checker = { enabled = true }, -- automatically check for plugin updates
|
||||
performance = {
|
||||
rtp = {
|
||||
-- uncomment the below to disable some rtp plugins
|
||||
disabled_plugins = {
|
||||
-- "gzip",
|
||||
-- "matchit",
|
||||
-- "matchparen",
|
||||
-- "netrwPlugin",
|
||||
-- "tarPlugin",
|
||||
-- "tohtml",
|
||||
-- "tutor",
|
||||
-- "zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue