nvim: Only load plugin spec if plugin files exist
Before we load the lazy spec from the 'lua/plugins' directory, we check that the directory exists and contains at least one .lua file. We do not check that the file returns a valid spec but that is just assumed in this case.
This commit is contained in:
parent
3e369ee31e
commit
f8625f35f0
1 changed files with 6 additions and 1 deletions
|
@ -31,8 +31,13 @@ if not vim.loop.fs_stat(lazypath) then
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
-- ensure plugins specs exist before loading into lazy
|
||||||
|
local spec_dir = vim.fn.stdpath("config") .. "/lua/plugins"
|
||||||
|
local spec_exist = (vim.fn.isdirectory(spec_dir) ~= 0) and (#vim.fn.glob(spec_dir .. "/*.lua", nil, true) ~= 0)
|
||||||
|
local spec = spec_exist and { import = "plugins" } or {}
|
||||||
|
|
||||||
require("lazy").setup({
|
require("lazy").setup({
|
||||||
spec = { { import = "plugins" } },
|
spec = { spec },
|
||||||
defaults = { lazy = true, version = "*" },
|
defaults = { lazy = true, version = "*" },
|
||||||
performance = {
|
performance = {
|
||||||
rtp = { disabled_plugins = { "netrw", "netrwPlugin" } },
|
rtp = { disabled_plugins = { "netrw", "netrwPlugin" } },
|
||||||
|
|
Loading…
Reference in a new issue