lazy.nvim/lua/lazy/core/config.lua

142 lines
4.1 KiB
Lua
Raw Normal View History

local Util = require("lazy.core.util")
2022-11-20 21:33:47 +00:00
local M = {}
---@class LazyConfig
M.defaults = {
root = vim.fn.stdpath("data") .. "/lazy", -- directory where plugins will be installed
defaults = {
2022-12-03 20:08:35 +00:00
lazy = false, -- should plugins be lazy-loaded?
version = nil,
-- version = "*", -- enable this to try installing the latest stable versions of plugins
},
2022-11-30 22:14:16 +00:00
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
concurrency = nil, ---@type number limit the maximum amount of concurrent tasks
2022-11-30 22:14:16 +00:00
git = {
-- defaults for the `Lazy log` command
-- log = { "-10" }, -- show the last 10 commits
log = { "--since=1 days ago" }, -- show commits from the last 3 days
timeout = 120, -- kill processes that take more than 2 minutes
url_format = "https://github.com/%s.git",
2022-11-30 22:14:16 +00:00
},
2022-11-30 22:08:00 +00:00
dev = {
-- directory where you store your local plugin projects
path = vim.fn.expand("~/projects"),
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
2022-11-30 22:08:00 +00:00
patterns = {}, -- For example {"folke"}
2022-11-20 21:34:55 +00:00
},
install = {
-- install missing plugins on startup. This doesn't increase startup time.
missing = true,
-- try to load one of these colorschemes when starting an installation during startup
colorscheme = { "habamax" },
},
2022-11-30 22:13:08 +00:00
ui = {
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
2022-11-23 18:06:04 +00:00
icons = {
cmd = "",
2022-11-23 18:06:04 +00:00
config = "",
event = "",
2022-11-30 22:13:08 +00:00
ft = "",
init = "",
keys = "",
plugin = "",
runtime = "",
source = "",
start = "",
2022-11-28 23:15:13 +00:00
task = "",
2022-11-23 18:06:04 +00:00
},
2022-11-30 22:13:35 +00:00
throttle = 20, -- how frequently should the ui process render events
2022-11-29 14:25:09 +00:00
},
2022-12-05 19:49:23 +00:00
checker = {
-- automcatilly check for plugin updates
2022-12-05 19:49:23 +00:00
enabled = false,
concurrency = nil, ---@type number? set to 1 to check for updates very slowly
notify = true, -- get a notification when new updates are found
frequency = 3600, -- check for updates every hour
2022-12-05 19:49:23 +00:00
},
performance = {
---@type LazyCacheConfig
cache = nil,
reset_packpath = true, -- reset the package path to improve startup time
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
-- "tarPlugin",
-- "tohtml",
-- "tutor",
-- "zipPlugin",
},
},
},
readme = {
root = vim.fn.stdpath("state") .. "/lazy/readme",
files = { "README.md" },
skip_if_doc_exists = true,
},
2022-12-02 15:52:22 +00:00
debug = false,
2022-11-20 21:33:47 +00:00
}
M.ns = vim.api.nvim_create_namespace("lazy")
---@type string|LazySpec Should be either a string pointing to a module, or a spec
M.spec = nil
2022-11-20 21:33:47 +00:00
---@type table<string, LazyPlugin>
M.plugins = {}
---@type LazyPlugin[]
M.to_clean = {}
2022-11-20 21:33:47 +00:00
---@type LazyConfig
M.options = {}
---@param spec LazySpec
2022-11-20 21:33:47 +00:00
---@param opts? LazyConfig
function M.setup(spec, opts)
M.spec = spec
2022-11-20 21:34:55 +00:00
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
M.options.performance.cache = require("lazy.core.cache")
table.insert(M.options.install.colorscheme, "habamax")
if M.options.performance.reset_packpath then
vim.go.packpath = ""
end
if M.options.performance.rtp.reset then
local me = debug.getinfo(1, "S").source:sub(2)
me = vim.fn.fnamemodify(me, ":p:h:h:h:h")
vim.opt.rtp = {
me,
vim.env.VIMRUNTIME,
vim.fn.stdpath("config"),
}
end
vim.opt.rtp:append(M.options.readme.root)
2022-11-20 21:33:47 +00:00
2022-12-14 20:25:11 +00:00
-- disable plugin loading since we do all of that ourselves
vim.go.loadplugins = false
2022-11-20 21:34:55 +00:00
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
once = true,
callback = function()
require("lazy.core.cache").autosave()
2022-11-20 22:25:56 +00:00
require("lazy.view").setup()
require("lazy.manage.reloader").enable()
2022-12-05 19:49:23 +00:00
if M.options.checker.enabled then
require("lazy.manage.checker").start()
end
2022-11-20 21:34:55 +00:00
end,
})
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
Util.very_lazy()
2022-11-20 21:33:47 +00:00
end
return M