refactor: support async online query engine:baidu
This commit is contained in:
@ -60,7 +60,7 @@ return {
|
||||
-- no = '❌'
|
||||
},
|
||||
theme = 'default',
|
||||
db_path = '$HOME/.vim/dict/ultimate.db',
|
||||
dir = '$HOME/.vim/dict',
|
||||
-- float = {
|
||||
-- width = 0.8,
|
||||
-- height = 0.8,
|
||||
|
0
lua/Trans/core/install.lua
Normal file
0
lua/Trans/core/install.lua
Normal file
@ -24,10 +24,22 @@ process = function(opts)
|
||||
end
|
||||
|
||||
|
||||
local res = require('Trans.backend').offline.query(data)
|
||||
-- vim.pretty_print(res)
|
||||
require('Trans.backend').baidu.query(data)
|
||||
local thread = coroutine.running()
|
||||
local resume = function()
|
||||
coroutine.resume(thread)
|
||||
end
|
||||
|
||||
local time = 0
|
||||
while data.result == nil do
|
||||
vim.defer_fn(resume, 400)
|
||||
time = time + 1
|
||||
print('waiting' .. ('.'):rep(time))
|
||||
coroutine.yield()
|
||||
end
|
||||
vim.pretty_print(data)
|
||||
|
||||
M.translate = coroutine.wrap(process)
|
||||
end
|
||||
|
||||
return process
|
||||
return coroutine.wrap(process)
|
||||
|
Reference in New Issue
Block a user