2022-11-22 20:28:08 +00:00
|
|
|
|
local Util = require("lazy.core.util")
|
2022-11-20 21:33:47 +00:00
|
|
|
|
|
2022-12-28 16:57:59 +00:00
|
|
|
|
---@class LazyCoreConfig
|
2022-11-20 21:33:47 +00:00
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
|
|
---@class LazyConfig
|
|
|
|
|
M.defaults = {
|
2022-12-03 14:48:06 +00:00
|
|
|
|
root = vim.fn.stdpath("data") .. "/lazy", -- directory where plugins will be installed
|
2022-11-30 22:08:40 +00:00
|
|
|
|
defaults = {
|
2022-12-03 20:08:35 +00:00
|
|
|
|
lazy = false, -- should plugins be lazy-loaded?
|
2022-11-30 22:12:00 +00:00
|
|
|
|
version = nil,
|
2022-11-30 22:08:40 +00:00
|
|
|
|
-- 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.
|
2022-12-14 20:03:53 +00:00
|
|
|
|
concurrency = nil, ---@type number limit the maximum amount of concurrent tasks
|
2022-11-30 22:14:16 +00:00
|
|
|
|
git = {
|
2022-12-14 20:03:53 +00:00
|
|
|
|
-- defaults for the `Lazy log` command
|
|
|
|
|
-- log = { "-10" }, -- show the last 10 commits
|
2022-12-20 13:13:52 +00:00
|
|
|
|
log = { "--since=3 days ago" }, -- show commits from the last 3 days
|
2022-12-14 20:03:53 +00:00
|
|
|
|
timeout = 120, -- kill processes that take more than 2 minutes
|
2022-12-13 09:09:33 +00:00
|
|
|
|
url_format = "https://github.com/%s.git",
|
2022-11-30 22:14:16 +00:00
|
|
|
|
},
|
2022-11-30 22:08:00 +00:00
|
|
|
|
dev = {
|
2022-12-14 20:03:53 +00:00
|
|
|
|
-- directory where you store your local plugin projects
|
2022-12-20 06:19:55 +00:00
|
|
|
|
path = "~/projects",
|
2022-12-14 20:03:53 +00:00
|
|
|
|
---@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
|
|
|
|
},
|
2022-12-02 18:18:10 +00:00
|
|
|
|
install = {
|
|
|
|
|
-- install missing plugins on startup. This doesn't increase startup time.
|
|
|
|
|
missing = true,
|
2022-12-14 20:03:53 +00:00
|
|
|
|
-- try to load one of these colorschemes when starting an installation during startup
|
2022-12-02 18:18:10 +00:00
|
|
|
|
colorscheme = { "habamax" },
|
|
|
|
|
},
|
2022-11-30 22:13:08 +00:00
|
|
|
|
ui = {
|
2022-12-20 18:29:28 +00:00
|
|
|
|
-- a number <1 is a percentage., >1 is a fixed size
|
|
|
|
|
size = { width = 0.8, height = 0.8 },
|
2022-11-30 22:13:08 +00:00
|
|
|
|
-- 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 = {
|
2022-12-26 09:24:47 +00:00
|
|
|
|
loaded = "●",
|
|
|
|
|
not_loaded = "○",
|
2022-12-05 22:14:04 +00:00
|
|
|
|
cmd = " ",
|
2022-11-23 18:06:04 +00:00
|
|
|
|
config = "",
|
|
|
|
|
event = "",
|
2022-11-30 22:13:08 +00:00
|
|
|
|
ft = " ",
|
2022-12-05 22:14:04 +00:00
|
|
|
|
init = " ",
|
|
|
|
|
keys = " ",
|
|
|
|
|
plugin = " ",
|
|
|
|
|
runtime = " ",
|
|
|
|
|
source = " ",
|
|
|
|
|
start = "",
|
2022-11-28 23:15:13 +00:00
|
|
|
|
task = "✔ ",
|
2022-12-25 12:41:33 +00:00
|
|
|
|
lazy = "鈴 ",
|
2022-12-26 09:24:47 +00:00
|
|
|
|
list = {
|
|
|
|
|
"●",
|
|
|
|
|
"➜",
|
|
|
|
|
"★",
|
|
|
|
|
"‒",
|
|
|
|
|
},
|
2022-11-23 18:06:04 +00:00
|
|
|
|
},
|
2022-12-30 19:41:23 +00:00
|
|
|
|
-- leave nil, to automatically select a browser depending on your OS.
|
|
|
|
|
-- If you want to use a specific browser, you can define it here
|
|
|
|
|
browser = nil, ---@type string?
|
2022-11-30 22:13:35 +00:00
|
|
|
|
throttle = 20, -- how frequently should the ui process render events
|
2022-12-24 10:28:19 +00:00
|
|
|
|
custom_keys = {
|
|
|
|
|
-- you can define custom key maps here.
|
|
|
|
|
-- To disable one of the defaults, set it to false
|
|
|
|
|
|
|
|
|
|
-- open lazygit log
|
|
|
|
|
["<localleader>l"] = function(plugin)
|
|
|
|
|
require("lazy.util").open_cmd({ "lazygit", "log" }, {
|
|
|
|
|
cwd = plugin.dir,
|
|
|
|
|
terminal = true,
|
|
|
|
|
close_on_exit = true,
|
|
|
|
|
enter = true,
|
|
|
|
|
})
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
-- open a terminal for the plugin dir
|
|
|
|
|
["<localleader>t"] = function(plugin)
|
|
|
|
|
require("lazy.util").open_cmd({ vim.go.shell }, {
|
|
|
|
|
cwd = plugin.dir,
|
|
|
|
|
terminal = true,
|
|
|
|
|
close_on_exit = true,
|
|
|
|
|
enter = true,
|
|
|
|
|
})
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-12-24 10:27:29 +00:00
|
|
|
|
diff = {
|
|
|
|
|
-- diff command <d> can be one of:
|
|
|
|
|
-- * browser: opens the github compare view. Note that this is always mapped to <K> as well,
|
|
|
|
|
-- so you can have a different command for diff <d>
|
|
|
|
|
-- * git: will run git diff and open a buffer with filetype git
|
|
|
|
|
-- * terminal_git: will open a pseudo terminal with git diff
|
|
|
|
|
-- * diffview.nvim: will open Diffview to show the diff
|
|
|
|
|
cmd = "git",
|
2022-11-29 14:25:09 +00:00
|
|
|
|
},
|
2022-12-05 19:49:23 +00:00
|
|
|
|
checker = {
|
2022-12-19 12:36:11 +00:00
|
|
|
|
-- automatically check for plugin updates
|
2022-12-05 19:49:23 +00:00
|
|
|
|
enabled = false,
|
2022-12-14 20:03:53 +00:00
|
|
|
|
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
|
|
|
|
},
|
2022-12-20 18:38:32 +00:00
|
|
|
|
change_detection = {
|
|
|
|
|
-- automatically check for config file changes and reload the ui
|
|
|
|
|
enabled = true,
|
|
|
|
|
notify = true, -- get a notification when changes are found
|
|
|
|
|
},
|
2022-12-02 11:43:34 +00:00
|
|
|
|
performance = {
|
|
|
|
|
---@type LazyCacheConfig
|
|
|
|
|
cache = nil,
|
2022-12-14 20:03:53 +00:00
|
|
|
|
reset_packpath = true, -- reset the package path to improve startup time
|
|
|
|
|
rtp = {
|
|
|
|
|
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
|
2022-12-21 14:19:14 +00:00
|
|
|
|
---@type string[]
|
|
|
|
|
paths = {}, -- add any custom paths here that you want to indluce in the rtp
|
2022-12-14 20:03:53 +00:00
|
|
|
|
---@type string[] list any plugins you want to disable here
|
|
|
|
|
disabled_plugins = {
|
|
|
|
|
-- "gzip",
|
|
|
|
|
-- "matchit",
|
|
|
|
|
-- "matchparen",
|
|
|
|
|
-- "netrwPlugin",
|
|
|
|
|
-- "tarPlugin",
|
|
|
|
|
-- "tohtml",
|
|
|
|
|
-- "tutor",
|
|
|
|
|
-- "zipPlugin",
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-12-02 11:43:34 +00:00
|
|
|
|
},
|
2022-12-15 13:34:08 +00:00
|
|
|
|
-- lazy can generate helptags from the headings in markdown readme files,
|
|
|
|
|
-- so :help works even for plugins that don't have vim docs.
|
|
|
|
|
-- when the readme opens with :help it will be correctly displayed as markdown
|
2022-12-15 13:07:37 +00:00
|
|
|
|
readme = {
|
|
|
|
|
root = vim.fn.stdpath("state") .. "/lazy/readme",
|
2023-01-01 19:23:41 +00:00
|
|
|
|
files = { "README.md", "lua/**/README.md" },
|
2022-12-15 13:34:08 +00:00
|
|
|
|
-- only generate markdown helptags for plugins that dont have docs
|
2022-12-15 13:07:37 +00:00
|
|
|
|
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")
|
|
|
|
|
|
2022-12-01 12:33:55 +00:00
|
|
|
|
---@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 = {}
|
|
|
|
|
|
2022-11-24 21:04:23 +00:00
|
|
|
|
---@type LazyPlugin[]
|
|
|
|
|
M.to_clean = {}
|
|
|
|
|
|
2022-11-20 21:33:47 +00:00
|
|
|
|
---@type LazyConfig
|
|
|
|
|
M.options = {}
|
|
|
|
|
|
2022-12-17 09:06:40 +00:00
|
|
|
|
---@type string
|
|
|
|
|
M.me = nil
|
|
|
|
|
|
2022-12-21 09:51:31 +00:00
|
|
|
|
---@type string
|
|
|
|
|
M.mapleader = nil
|
|
|
|
|
|
2022-12-21 21:28:09 +00:00
|
|
|
|
M.headless = #vim.api.nvim_list_uis() == 0
|
|
|
|
|
|
2022-12-01 12:33:55 +00:00
|
|
|
|
---@param spec LazySpec
|
2022-11-20 21:33:47 +00:00
|
|
|
|
---@param opts? LazyConfig
|
2022-12-01 12:33:55 +00:00
|
|
|
|
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 {})
|
2022-12-02 11:43:34 +00:00
|
|
|
|
M.options.performance.cache = require("lazy.core.cache")
|
2022-12-02 18:18:10 +00:00
|
|
|
|
table.insert(M.options.install.colorscheme, "habamax")
|
|
|
|
|
|
2022-12-20 06:19:55 +00:00
|
|
|
|
M.options.root = Util.norm(M.options.root)
|
|
|
|
|
M.options.dev.path = Util.norm(M.options.dev.path)
|
|
|
|
|
M.options.lockfile = Util.norm(M.options.lockfile)
|
|
|
|
|
M.options.readme.root = Util.norm(M.options.readme.root)
|
|
|
|
|
|
2022-12-02 11:52:06 +00:00
|
|
|
|
if M.options.performance.reset_packpath then
|
2022-12-29 15:04:45 +00:00
|
|
|
|
vim.go.packpath = vim.env.VIMRUNTIME
|
2022-12-01 10:23:34 +00:00
|
|
|
|
end
|
2022-12-20 15:02:06 +00:00
|
|
|
|
|
|
|
|
|
M.me = debug.getinfo(1, "S").source:sub(2)
|
|
|
|
|
M.me = Util.norm(vim.fn.fnamemodify(M.me, ":p:h:h:h:h"))
|
2022-12-14 20:03:53 +00:00
|
|
|
|
if M.options.performance.rtp.reset then
|
2022-12-03 16:42:54 +00:00
|
|
|
|
vim.opt.rtp = {
|
2022-12-29 07:21:22 +00:00
|
|
|
|
vim.fn.stdpath("config"),
|
2022-12-29 15:03:23 +00:00
|
|
|
|
M.me,
|
2022-12-14 20:03:53 +00:00
|
|
|
|
vim.env.VIMRUNTIME,
|
2022-12-20 14:03:16 +00:00
|
|
|
|
vim.fn.fnamemodify(vim.v.progpath, ":p:h:h") .. "/lib/nvim",
|
2022-12-15 22:23:18 +00:00
|
|
|
|
vim.fn.stdpath("config") .. "/after",
|
2022-12-03 16:42:54 +00:00
|
|
|
|
}
|
|
|
|
|
end
|
2022-12-21 14:19:14 +00:00
|
|
|
|
for _, path in ipairs(M.options.performance.rtp.paths) do
|
|
|
|
|
vim.opt.rtp:append(path)
|
|
|
|
|
end
|
2022-12-15 13:07:37 +00:00
|
|
|
|
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-12-21 09:51:31 +00:00
|
|
|
|
M.mapleader = vim.g.mapleader
|
2022-12-14 20:25:11 +00:00
|
|
|
|
|
2022-12-21 21:28:09 +00:00
|
|
|
|
if M.headless then
|
|
|
|
|
require("lazy.view.commands").setup()
|
|
|
|
|
else
|
2022-12-27 12:34:07 +00:00
|
|
|
|
vim.api.nvim_create_autocmd("UIEnter", {
|
|
|
|
|
callback = function()
|
|
|
|
|
require("lazy.stats").on_ui_enter()
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
2022-12-21 21:28:09 +00:00
|
|
|
|
vim.api.nvim_create_autocmd("User", {
|
|
|
|
|
pattern = "VeryLazy",
|
|
|
|
|
once = true,
|
|
|
|
|
callback = function()
|
|
|
|
|
require("lazy.core.cache").autosave()
|
|
|
|
|
require("lazy.view.commands").setup()
|
|
|
|
|
if M.options.change_detection.enabled then
|
|
|
|
|
require("lazy.manage.reloader").enable()
|
|
|
|
|
end
|
|
|
|
|
if M.options.checker.enabled then
|
|
|
|
|
vim.defer_fn(function()
|
|
|
|
|
require("lazy.manage.checker").start()
|
|
|
|
|
end, 10)
|
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
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
|