Skip to content
This repository was archived by the owner on Dec 7, 2025. It is now read-only.

Commit 53956b0

Browse files
committed
update
1 parent e8b8da0 commit 53956b0

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

lua/strive/init.lua

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,18 @@ function Async.retry(promise_fn, max_retries, initial_delay)
289289
end
290290
end
291291

292+
function Async.scandir(dir)
293+
return function(callback)
294+
uv.fs_scandir(dir, function(err, handle)
295+
if err then
296+
callback(Result.failure(err))
297+
else
298+
callback(Result.success(handle))
299+
end
300+
end)
301+
end
302+
end
303+
292304
-- =====================================================================
293305
-- 3. Task Queue
294306
-- =====================================================================
@@ -743,23 +755,20 @@ function Plugin:load_scripts()
743755
local plugin_path = self:get_path()
744756
local plugin_dir = vim.fs.joinpath(plugin_path, 'plugin')
745757

746-
local handle = uv.fs_scandir(plugin_dir)
747-
if not handle then
758+
local result = Async.try_await(Async.scandir(plugin_dir))
759+
if not result.success or not result.value or not result.value[2] then
760+
M.log('debug', string.format('Plugin directory not found: %s', plugin_dir))
748761
return
749762
end
750763

751764
while true do
752-
local name, type = uv.fs_scandir_next(handle)
765+
local name, type = uv.fs_scandir_next(result.value[2])
753766
if not name then
754767
break
755768
end
756-
757769
if type == 'file' and (name:match('%.lua$') or name:match('%.vim$')) then
758770
local file_path = vim.fs.joinpath(plugin_dir, name)
759-
760-
vim.schedule(function()
761-
vim.cmd('source ' .. vim.fn.fnameescape(file_path))
762-
end)
771+
vim.cmd('source ' .. vim.fn.fnameescape(file_path))
763772
end
764773
end
765774
end)()

0 commit comments

Comments
 (0)