aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/core/async
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-05-11 16:10:57 +0200
committerGitHub <noreply@github.com>2022-05-11 16:10:57 +0200
commit5e3385d90668c792919c7e2791620a6c0d569538 (patch)
tree4b0158d3ac7765db47411d57ec754a96f8eaf1f9 /lua/nvim-lsp-installer/core/async
parentchore!: remove zeta_note (diff)
downloadmason-5e3385d90668c792919c7e2791620a6c0d569538.tar
mason-5e3385d90668c792919c7e2791620a6c0d569538.tar.gz
mason-5e3385d90668c792919c7e2791620a6c0d569538.tar.bz2
mason-5e3385d90668c792919c7e2791620a6c0d569538.tar.lz
mason-5e3385d90668c792919c7e2791620a6c0d569538.tar.xz
mason-5e3385d90668c792919c7e2791620a6c0d569538.tar.zst
mason-5e3385d90668c792919c7e2791620a6c0d569538.zip
chore: further decouple module structure (#685)
Diffstat (limited to 'lua/nvim-lsp-installer/core/async')
-rw-r--r--lua/nvim-lsp-installer/core/async/init.lua11
-rw-r--r--lua/nvim-lsp-installer/core/async/uv.lua12
2 files changed, 11 insertions, 12 deletions
diff --git a/lua/nvim-lsp-installer/core/async/init.lua b/lua/nvim-lsp-installer/core/async/init.lua
index 27a4c7cb..794a9b35 100644
--- a/lua/nvim-lsp-installer/core/async/init.lua
+++ b/lua/nvim-lsp-installer/core/async/init.lua
@@ -1,3 +1,4 @@
+local functional = require "nvim-lsp-installer.core.functional"
local co = coroutine
local exports = {}
@@ -10,7 +11,7 @@ function Promise.new(resolver)
end
---@param success boolean
----@param cb fun()
+---@param cb fun(success: boolean, value: table)
function Promise:_wrap_resolver_cb(success, cb)
return function(...)
if self.has_resolved then
@@ -106,13 +107,13 @@ exports.scope = function(suspend_fn)
end
end
-exports.run_blocking = function(suspend_fn)
+exports.run_blocking = function(suspend_fn, ...)
local resolved, ok, result
local cancel_coroutine = new_execution_context(suspend_fn, function(a, b)
resolved = true
ok = a
result = b
- end)
+ end, ...)
if vim.wait(60000, function()
return resolved == true
@@ -212,4 +213,8 @@ exports.wait_all = function(suspend_fns)
return unpack(results)
end
+function exports.blocking(suspend_fn)
+ return functional.partial(exports.run_blocking, suspend_fn)
+end
+
return exports
diff --git a/lua/nvim-lsp-installer/core/async/uv.lua b/lua/nvim-lsp-installer/core/async/uv.lua
index a25aeb0b..69af4f26 100644
--- a/lua/nvim-lsp-installer/core/async/uv.lua
+++ b/lua/nvim-lsp-installer/core/async/uv.lua
@@ -2,15 +2,9 @@ local a = require "nvim-lsp-installer.core.async"
---@type table<UvMethod, async fun(...)>
local M = setmetatable({}, {
- __index = function(_, method)
- ---@async
- return function(...)
- local err, result = a.promisify(vim.loop[method])(...)
- if err then
- error(err, 2)
- end
- return result
- end
+ __index = function(cache, method)
+ cache[method] = a.promisify(vim.loop[method], true)
+ return cache[method]
end,
})