2022-11-23 04:28:08 +08:00
|
|
|
local Util = require("lazy.core.util")
|
2022-11-21 05:33:47 +08:00
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
---@class LazyConfig
|
|
|
|
M.defaults = {
|
2022-12-01 06:08:40 +08:00
|
|
|
defaults = {
|
2022-12-01 18:06:44 +08:00
|
|
|
lazy = false, -- should plugins be loaded at startup?
|
2022-12-01 06:12:00 +08:00
|
|
|
version = nil,
|
2022-12-01 06:08:40 +08:00
|
|
|
-- version = "*", -- enable this to try installing the latest stable versions of plugins
|
|
|
|
},
|
2022-12-01 06:14:16 +08:00
|
|
|
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
|
|
|
install_missing = true, -- install missing plugins on startup. This doesn't increase startup time.
|
2022-12-01 06:14:31 +08:00
|
|
|
concurrency = nil, -- set to a number to limit the maximum amount of concurrent tasks
|
2022-12-01 06:14:16 +08:00
|
|
|
git = {
|
|
|
|
-- defaults for `Lazy log`
|
|
|
|
-- log = { "-10" }, -- last 10 commits
|
|
|
|
log = { "--since=1 days ago" }, -- commits from the last 3 days
|
2022-12-01 06:38:45 +08:00
|
|
|
timeout = 120, -- processes taking over 2 minutes will be killed
|
2022-12-01 06:14:16 +08:00
|
|
|
},
|
2022-12-01 18:23:34 +08:00
|
|
|
package = {
|
|
|
|
path = vim.fn.stdpath("data") .. "/site",
|
|
|
|
name = "lazy", -- plugins will be installed under package.path/pack/{name}/opt
|
|
|
|
reset = true, -- packpath will be reset to only include lazy. This makes packadd a lot faster
|
|
|
|
},
|
2022-12-01 06:14:16 +08:00
|
|
|
-- Any plugin spec that contains one of the patterns will use your
|
|
|
|
-- local repo in the projects folder instead of fetchig it from github
|
|
|
|
-- Mostly useful for plugin developers.
|
2022-12-01 06:08:00 +08:00
|
|
|
dev = {
|
|
|
|
path = vim.fn.expand("~/projects"), -- the path where you store your projects
|
2022-11-25 05:04:23 +08:00
|
|
|
---@type string[]
|
2022-12-01 06:08:00 +08:00
|
|
|
patterns = {}, -- For example {"folke"}
|
2022-11-21 05:34:55 +08:00
|
|
|
},
|
2022-12-01 06:13:08 +08:00
|
|
|
ui = {
|
|
|
|
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
|
|
|
|
border = "none",
|
2022-11-24 02:06:04 +08:00
|
|
|
icons = {
|
|
|
|
start = "",
|
2022-11-29 19:02:25 +08:00
|
|
|
plugin = " ",
|
2022-11-24 02:06:04 +08:00
|
|
|
source = " ",
|
|
|
|
config = "",
|
|
|
|
event = "",
|
|
|
|
keys = " ",
|
|
|
|
cmd = " ",
|
2022-12-01 06:13:08 +08:00
|
|
|
ft = " ",
|
2022-11-29 07:15:13 +08:00
|
|
|
task = "✔ ",
|
2022-11-24 02:06:04 +08:00
|
|
|
},
|
2022-12-01 06:13:35 +08:00
|
|
|
throttle = 20, -- how frequently should the ui process render events
|
2022-11-29 22:25:09 +08:00
|
|
|
},
|
2022-11-21 05:33:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
M.ns = vim.api.nvim_create_namespace("lazy")
|
|
|
|
|
2022-12-01 20:33:55 +08:00
|
|
|
---@type string|LazySpec Should be either a string pointing to a module, or a spec
|
|
|
|
M.spec = nil
|
|
|
|
|
|
|
|
---@type string Opt directory where plugins will be installed
|
|
|
|
M.root = nil
|
2022-11-25 05:04:23 +08:00
|
|
|
|
2022-11-21 05:33:47 +08:00
|
|
|
---@type table<string, LazyPlugin>
|
|
|
|
M.plugins = {}
|
|
|
|
|
2022-11-25 05:04:23 +08:00
|
|
|
---@type LazyPlugin[]
|
|
|
|
M.to_clean = {}
|
|
|
|
|
2022-11-21 05:33:47 +08:00
|
|
|
---@type LazyConfig
|
|
|
|
M.options = {}
|
|
|
|
|
2022-12-01 20:33:55 +08:00
|
|
|
---@param spec LazySpec
|
2022-11-21 05:33:47 +08:00
|
|
|
---@param opts? LazyConfig
|
2022-12-01 20:33:55 +08:00
|
|
|
function M.setup(spec, opts)
|
|
|
|
M.spec = spec
|
2022-11-21 05:34:55 +08:00
|
|
|
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
|
2022-12-01 20:33:55 +08:00
|
|
|
M.root = M.options.package.path .. "/pack/" .. M.options.package.name .. "/opt"
|
2022-12-01 18:23:34 +08:00
|
|
|
|
|
|
|
if M.options.package.reset then
|
|
|
|
vim.go.packpath = M.options.package.path
|
|
|
|
end
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-21 05:34:55 +08:00
|
|
|
vim.api.nvim_create_autocmd("User", {
|
|
|
|
pattern = "VeryLazy",
|
|
|
|
once = true,
|
|
|
|
callback = function()
|
2022-11-30 21:19:50 +08:00
|
|
|
require("lazy.core.module").autosave()
|
2022-11-21 06:25:56 +08:00
|
|
|
require("lazy.view").setup()
|
2022-11-21 05:34:55 +08:00
|
|
|
end,
|
|
|
|
})
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-21 05:34:55 +08:00
|
|
|
Util.very_lazy()
|
2022-11-21 05:33:47 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|