diff options
Diffstat (limited to 'lua/nvim-lsp-installer/core/installer/context.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/core/installer/context.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/core/installer/context.lua b/lua/nvim-lsp-installer/core/installer/context.lua index 5705fa41..f97f334f 100644 --- a/lua/nvim-lsp-installer/core/installer/context.lua +++ b/lua/nvim-lsp-installer/core/installer/context.lua @@ -4,6 +4,8 @@ local fs = require "nvim-lsp-installer.core.fs" local path = require "nvim-lsp-installer.path" local platform = require "nvim-lsp-installer.platform" local receipt = require "nvim-lsp-installer.core.receipt" +local installer = require "nvim-lsp-installer.core.installer" +local a = require "nvim-lsp-installer.core.async" ---@class ContextualSpawn ---@field cwd CwdManager @@ -139,4 +141,17 @@ function InstallContext:promote_cwd() self.cwd:set(self.destination_dir) end +---Runs the provided async functions concurrently and returns their result, once all are resolved. +---This is really just a wrapper around a.wait_all() that makes sure to patch the coroutine context before creating the +---new async execution contexts. +---@async +---@param suspend_fns async fun(ctx: InstallContext)[] +function InstallContext:run_concurrently(suspend_fns) + return a.wait_all(vim.tbl_map(function(suspend_fn) + return function() + return installer.run_installer(self, suspend_fn) + end + end, suspend_fns)) +end + return InstallContext |
