diff --git a/lua/blink/cmp/completion/accept/init.lua b/lua/blink/cmp/completion/accept/init.lua index 114c0041..f729d47e 100644 --- a/lua/blink/cmp/completion/accept/init.lua +++ b/lua/blink/cmp/completion/accept/init.lua @@ -81,8 +81,7 @@ local function accept(ctx, item, callback) end -- Notify the rust module that the item was accessed - -- TODO: why is this so slow? (10ms) - vim.schedule(function() require('blink.cmp.fuzzy').access(item) end) + require('blink.cmp.fuzzy').access(item) end) end) :catch(function(err) vim.notify(err, vim.log.levels.ERROR) end) diff --git a/lua/blink/cmp/fuzzy/init.lua b/lua/blink/cmp/fuzzy/init.lua index 39fda80f..40c662e8 100644 --- a/lua/blink/cmp/fuzzy/init.lua +++ b/lua/blink/cmp/fuzzy/init.lua @@ -21,7 +21,11 @@ end ---@param item blink.cmp.CompletionItem function fuzzy.access(item) fuzzy.init_db() - fuzzy.rust.access(item) + + -- writing to the db takes ~10ms, so schedule writes in another thread + vim.uv + .new_work(function(itm) require('blink.cmp.fuzzy.rust').access(vim.mpack.decode(itm)) end, function() end) + :queue(vim.mpack.encode(item)) end ---@param lines string