Closed
Description
Feature already in Vim?
No
Feature description
Problem
Libuv provides some pretty cool ways to enable multithreading, however they have some pretty big limitations:
- They only support passing simple types (
nil
,number
,boolean
,string
,userdata
) to/from the main thread. - None of the nvim-lua globals (
vim.*
) are available within the thread.
Solution
Expose all/some of vim.*
to uv threads.
At a minimum we should be able to expose: mpack, xdiff and cjson (maybe even treesitter). mpack will resolve 1) since it will allow us to serialize/deseralize more complex types.
Example
local a = ...;
local b = ...;
vim.loop.new_work(
function(a0, b0)
return vim.diff(a0, b0)
end,
function(r)
[use diff result]
end
):queue(a, b)