1
Fork 0
nixos-system-config/users/hu/packages/nvim/config/lua/util/require_dir.lua
caem 75b13ac379
Refactor the entire configuration
With the release of the Nvidia 555 beta drivers and their improvements to
the Wayland experience I've finally decided to return to NixOS with
Hyprland again after 2 years of running Gentoo and Opensuse Tumbleweed
on X11. So this is me committing the work done so far from the last
couple of days. Future commits will be more incremental.
2024-05-24 21:33:00 +02:00

27 lines
744 B
Lua

return function(dir, skip_init)
local returns = {}
local lua_files = vim.split(vim.fn.glob(dir.."/*.lua"), "\n")
local namespace = string.gsub(dir, vim.fn.stdpath("config").."/lua/", "")
namespace = string.gsub(namespace, "%/", ".")
for _, file in ipairs(lua_files) do
file = string.gsub(file, "%.lua", "")
file = string.gsub(file, dir.."/", namespace)
if skip_init and file == namespace.."init" then
goto continue
end
local require_ok, require_return = pcall(require, file)
if require_ok then
table.insert(returns, require_return)
else
vim.notify("Could not require file: '"..file.."': "..require_return, vim.log.levels.WARNING)
end
::continue::
end
return returns
end