diff --git a/lua/blink/cmp/lib/async.lua b/lua/blink/cmp/lib/async.lua index b9c39ac3..129e9794 100644 --- a/lua/blink/cmp/lib/async.lua +++ b/lua/blink/cmp/lib/async.lua @@ -9,6 +9,7 @@ --- @field cancel fun(self: blink.cmp.Task) --- @field map fun(self: blink.cmp.Task, fn: fun(result: any): blink.cmp.Task | any): blink.cmp.Task --- @field catch fun(self: blink.cmp.Task, fn: fun(err: any): blink.cmp.Task | any): blink.cmp.Task +--- @field schedule fun(self: blink.cmp.Task): blink.cmp.Task --- --- @field on_completion fun(self: blink.cmp.Task, cb: fun(result: any)) --- @field on_failure fun(self: blink.cmp.Task, cb: fun(err: any)) @@ -133,6 +134,14 @@ function task:catch(fn) return chained_task end +function task:schedule() + return self:map(function(value) + return task.new(function(resolve) + vim.schedule(function() resolve(value) end) + end) + end) +end + --- events function task:on_completion(cb) diff --git a/lua/blink/cmp/sources/cmdline/init.lua b/lua/blink/cmp/sources/cmdline/init.lua index 49ca2adf..d652b120 100644 --- a/lua/blink/cmp/sources/cmdline/init.lua +++ b/lua/blink/cmp/sources/cmdline/init.lua @@ -72,6 +72,7 @@ function cmdline:get_completions(context, callback) return completions end) + :schedule() :map(function(completions) local items = {} for _, completion in ipairs(completions) do