Skip to content

Expose vim.* to uv threadsย #15655

Closed
Closed
@lewis6991

Description

@lewis6991

Feature already in Vim?

No

Feature description

Problem

Libuv provides some pretty cool ways to enable multithreading, however they have some pretty big limitations:

  1. They only support passing simple types (nil, number, boolean, string, userdata) to/from the main thread.
  2. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions