-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a plan to support asynchronous? #157
Comments
hmmm no async support, but you can use callbacks. For example you can vim.schedule vim.schedule({callback}) *vim.schedule()*
Schedules {callback} to be invoked soon by the main event-loop. Useful
to avoid |textlock| or other temporary restrictions.
for example vim.schedule(function()
local todos = todos:get { where = { id = 1 } }
myFunctionThatProcessTodos(todos)
end) I'm sure there is something wrong you are doing not sure what. I'd suggest looking at existing applications likes |
Thanks, I found out today that /tmp/t.lua local function work_callback()
local sqlite_path = '/mnt/64d0d217-1a4c-4258-860b-02fbc3ade743/note/nvim/config/nvim/pack/packer/start/sqlite.lua/lua/?.lua;'
local file = '/mnt/64d0d217-1a4c-4258-860b-02fbc3ade743/note/nvim/config/nvim/data/translate/help.db'
package.path = sqlite_path .. package.path
local sqlite= require('sqlite.db')
local db = sqlite.new(file):open()
ok = db:exists('sentence')
db:close()
return ok
end
local function after_work_callback(arg1)
print(arg1)
end
local work = vim.loop.new_work(work_callback, after_work_callback)
work:queue() error message
|
I tested: local function work_callback()
local sqlite = require "sqlite.db"
local db = sqlite.new("/tmp/test.db"):open()
ok = db:exists "sentence"
db:close()
return ok
end
local function after_work_callback(arg1)
print(arg1)
end
local work = vim.loop.new_work(work_callback, after_work_callback)
work:queue() luafile % In make case, the error I get ...im/site/pack/packer/start/sqlite.lua/lua/sqlite/defs.lua:11: attempt to index field 'g' (a nil value) Then after few runs, Error in luv thread:
test.lua:2: loop or previous error loading module 'sqlite.db' @Conni2461 any thoughts why The loop or previous error loading might be because of require_on_index hack? --- taken from https://github.com/tjdevries/lazy.nvim/blob/master/lua/lazy.lua
M.require_on_index = function(require_path)
return setmetatable({}, {
__index = function(_, key)
return require(require_path)[key]
end,
__newindex = function(_, key, value)
require(require_path)[key] = value
end,
})
end |
i think this is the reson,
|
Can you use vim.loop.new_work in sqlite.lua to implement asynchronous |
I'm using a standard hard drive, and then every time I insert data vim lags a bit
The text was updated successfully, but these errors were encountered: