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

Commit a054d6f

Browse files
committed
update
1 parent 2093296 commit a054d6f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lua/strive/init.lua

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ function Result.failure(err)
6262
return setmetatable({ success = false, value = nil, error = err }, Result)
6363
end
6464

65+
function Async.safe_schedule(callback)
66+
if not vim.in_fast_event() then
67+
callback()
68+
return
69+
end
70+
vim.schedule(callback)
71+
end
72+
6573
-- Wrap a function to return a promise
6674
function Async.wrap(func)
6775
return function(...)
@@ -150,7 +158,7 @@ function Async.await(promise)
150158
end
151159

152160
promise(function(result)
153-
Async.safe_schedule(function()
161+
vim.schedule(function()
154162
local ok = coroutine.resume(co, result)
155163
if not ok then
156164
vim.notify(debug.traceback(co), vim.log.levels.ERROR)
@@ -176,7 +184,7 @@ function Async.try_await(promise)
176184
end
177185

178186
promise(function(result)
179-
Async.safe_schedule(function()
187+
vim.schedule(function()
180188
local ok = coroutine.resume(co, result)
181189
if not ok then
182190
vim.notify(debug.traceback(co), vim.log.levels.ERROR)
@@ -208,7 +216,7 @@ function Async.async(func)
208216
local function step(...)
209217
local ok, err = coroutine.resume(co, ...)
210218
if not ok then
211-
Async.safe_schedule(function()
219+
vim.schedule(function()
212220
vim.notify('Coroutine error: ' .. debug.traceback(co, err), vim.log.levels.ERROR)
213221
end)
214222
end
@@ -305,14 +313,6 @@ function Async.scandir(dir)
305313
end
306314
end
307315

308-
function Async.safe_schedule(callback)
309-
if not vim.in_fast_event() then
310-
callback()
311-
return
312-
end
313-
vim.schedule(callback)
314-
end
315-
316316
-- =====================================================================
317317
-- 3. Task Queue
318318
-- =====================================================================
@@ -693,12 +693,12 @@ function Plugin:load(opts)
693693
end
694694
end
695695
end
696+
696697
if self.config_opts then
697698
load_opts(self.config_opts)
698699
end
699-
-- Update status
700-
self.status = STATUS.LOADED
701700

701+
self.status = STATUS.LOADED
702702
pcall(api.nvim_del_augroup_by_name, 'strive_' .. self.plugin_name)
703703
return true
704704
end

0 commit comments

Comments
 (0)