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

272 lines
8.6 KiB
Lua
Raw Normal View History

local Util = require("lazy.core.util")
2022-11-20 21:33:47 +00:00
---@class LazyCoreConfig
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,
-- default `cond` you can use to globally disable a lot of plugins
-- when running inside vscode for example
cond = nil, ---@type boolean|fun(self:LazyPlugin):boolean|nil
-- version = "*", -- enable this to try installing the latest stable versions of plugins
},
-- leave nil when passing the spec as the first argument to setup()
spec = nil, ---@type LazySpec
2022-11-30 22:14:16 +00:00
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
concurrency = jit.os:find("Windows") and (vim.loop.available_parallelism() * 2) or 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 = { "-8" }, -- show commits from the last 3 days
timeout = 120, -- kill processes that take more than 2 minutes
url_format = "https://github.com/%s.git",
-- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version,
2023-03-06 06:39:56 +00:00
-- then set the below to false. This should work, but is NOT supported and will
-- increase downloads a lot.
filter = true,
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
2022-12-20 06:19:55 +00:00
path = "~/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"}
fallback = false, -- Fallback to git when local plugin doesn't exist
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 = {
-- a number <1 is a percentage., >1 is a fixed size
size = { width = 0.8, height = 0.8 },
wrap = true, -- wrap the lines in the ui
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",
title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right"
-- Show pills on top of the Lazy window
pills = true, ---@type boolean
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 = "",
import = "",
keys = "",
lazy = "󰒲 ",
loaded = "",
not_loaded = "",
plugin = "",
runtime = "",
require = "󰢱 ",
source = "",
start = "",
2022-11-28 23:15:13 +00:00
task = "",
list = {
"",
"",
"",
"",
},
2022-11-23 18:06:04 +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
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").float_term({ "lazygit", "log" }, {
cwd = plugin.dir,
})
end,
-- open a terminal for the plugin dir
["<localleader>t"] = function(plugin)
require("lazy.util").float_term(nil, {
cwd = plugin.dir,
})
end,
},
},
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,
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
},
change_detection = {
-- automatically check for config file changes and reload the ui
enabled = true,
notify = true, -- get a notification when changes are found
},
performance = {
cache = {
enabled = true,
},
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[]
2023-01-22 14:24:13 +00:00
paths = {}, -- add any custom paths here that you want to includes in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
-- "tarPlugin",
-- "tohtml",
-- "tutor",
-- "zipPlugin",
},
},
},
-- 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
readme = {
enabled = true,
root = vim.fn.stdpath("state") .. "/lazy/readme",
files = { "README.md", "lua/**/README.md" },
-- only generate markdown helptags for plugins that dont have docs
skip_if_doc_exists = true,
},
state = vim.fn.stdpath("state") .. "/lazy/state.json", -- state info for checker and other things
build = {
-- Plugins can provide a `build.lua` file that will be executed when the plugin is installed
-- or updated. When the plugin spec also has a `build` command, the plugin's `build.lua` not be
-- executed. In this case, a warning message will be shown.
warn_on_override = true,
},
-- Enable profiling of lazy.nvim. This will add some overhead,
-- so only enable this when you are debugging lazy.nvim
profiling = {
-- Enables extra stats on the debug tab related to the loader cache.
-- Additionally gathers stats about all package.loaders
loader = false,
-- Track each new require in the Lazy profiling tab
require = false,
},
2022-12-02 15:52:22 +00:00
debug = false,
2022-11-20 21:33:47 +00:00
}
M.version = "10.9.1" -- x-release-please-version
2022-11-20 21:33:47 +00:00
M.ns = vim.api.nvim_create_namespace("lazy")
---@type LazySpecLoader
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 = {}
2022-12-17 09:06:40 +00:00
---@type string
M.me = nil
---@type string
M.mapleader = nil
function M.headless()
return #vim.api.nvim_list_uis() == 0
end
2022-11-20 21:33:47 +00:00
---@param opts? LazyConfig
function M.setup(opts)
2022-11-20 21:34:55 +00:00
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
if type(M.options.spec) == "string" then
M.options.spec = { import = M.options.spec }
end
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)
vim.fn.mkdir(M.options.root, "p")
if M.options.performance.reset_packpath then
vim.go.packpath = vim.env.VIMRUNTIME
end
M.me = debug.getinfo(1, "S").source:sub(2)
M.me = Util.norm(vim.fn.fnamemodify(M.me, ":p:h:h:h:h"))
if M.options.performance.rtp.reset then
vim.opt.rtp = {
vim.fn.stdpath("config"),
vim.fn.stdpath("data") .. "/site",
M.me,
vim.env.VIMRUNTIME,
vim.fn.fnamemodify(vim.v.progpath, ":p:h:h") .. "/lib/nvim",
vim.fn.stdpath("config") .. "/after",
}
end
for _, path in ipairs(M.options.performance.rtp.paths) do
vim.opt.rtp:append(path)
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
M.mapleader = vim.g.mapleader
2022-12-14 20:25:11 +00:00
if M.headless() then
require("lazy.view.commands").setup()
end
2022-11-20 21:33:47 +00:00
vim.api.nvim_create_autocmd("UIEnter", {
once = true,
callback = function()
require("lazy.stats").on_ui_enter()
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
once = true,
callback = function()
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,
})
2022-11-20 21:34:55 +00:00
Util.very_lazy()
2022-11-20 21:33:47 +00:00
end
return M