Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
4505e5da18 Partial code for loading extensions 2024-02-14 23:47:17 +01:00

38
lua/scratchpad.lua Normal file
View file

@ -0,0 +1,38 @@
local module_root = function(--[[modname]]_)
return '/Users/fernando/.dotfiles/config/nvim/lua/hello'
end
local scan_dir = function(path, callback)
local handle = vim.loop.fs_scandir(path)
while handle do
local name, type = vim.loop.fs_scandir_next(handle)
if not name then break end
callback(path .. '/' .. name, name, type)
end
end
local scan_module = function(modname, callback)
local root = module_root(modname)
if not root then return end
scan_dir(root, function(path, name, type)
if name == 'init.lua' then
callback(modname)
elseif (type == 'file' or type == 'link') and name:sub(-4) == '.lua' then
callback(modname .. '.' .. name:sub(1, -5))
elseif type == 'directory' and vim.loop.fs_stat(path .. '/init.lua') then
callback(modname .. '.' .. name)
end
end)
end
local merge_module = function(modname)
local modules = {}
scan_module(modname, function(name)
table.insert(modules, require(name))
end)
return vim.tbl_extend('force', {}, unpack(modules))
end
P(merge_module('hello'))