diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 66d5ca0..74c1fc6 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -1,19 +1,44 @@ local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end end vim.opt.rtp:prepend(lazypath) +local function generate_import_specs() + local specs = {} + + local function add_specs_from_dir(path) + local uv = vim.loop + local stats = uv.fs_readdir(uv.fs_opendir(vim.fn.stdpath("config") .. "/" .. "lua" .. "/" .. path, nil, 1000)) + if not stats then + return + end + for _, stat in ipairs(stats) do + -- print(stat.name) + if stat.type == "directory" then + local new_import_path = path .. "/" .. stat.name + table.insert(specs, { import = new_import_path:gsub("/", ".") }) + add_specs_from_dir(new_import_path) + elseif stat.name == "init.lua" then + table.remove(specs) -- removes last element + end + end + end + + add_specs_from_dir("plugins") + return specs +end + require("lazy").setup({ spec = { -- add LazyVim and import its plugins