mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat(loader): automatically lazy-load colorschemes
This commit is contained in:
parent
210d1703ec
commit
07b467738d
2 changed files with 26 additions and 0 deletions
|
@ -37,6 +37,12 @@ function M.setup()
|
|||
M.disabled_rtp_plugins[file] = true
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorSchemePre", {
|
||||
callback = function(event)
|
||||
M.colorscheme(event.match)
|
||||
end,
|
||||
})
|
||||
|
||||
-- autoload opt plugins
|
||||
table.insert(package.loaders, M.autoload)
|
||||
end
|
||||
|
@ -191,6 +197,22 @@ function M.source(path)
|
|||
Util.track()
|
||||
end
|
||||
|
||||
function M.colorscheme(name)
|
||||
if vim.tbl_contains(vim.fn.getcompletion("", "color"), name) then
|
||||
return
|
||||
end
|
||||
for _, plugin in pairs(Config.plugins) do
|
||||
if not plugin._.loaded then
|
||||
for _, ext in ipairs({ "lua", "vim" }) do
|
||||
local path = plugin.dir .. "/colors/" .. name .. "." .. ext
|
||||
if vim.loop.fs_stat(path) then
|
||||
return M.load(plugin, { colorscheme = name })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- This loader is added as the very last one.
|
||||
-- This only hits when the modname is not cached and
|
||||
-- even then only once per plugin. So pretty much never.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue