aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/mason/api/command.lua25
1 files changed, 13 insertions, 12 deletions
diff --git a/lua/mason/api/command.lua b/lua/mason/api/command.lua
index 4be13d86..8fba7ea0 100644
--- a/lua/mason/api/command.lua
+++ b/lua/mason/api/command.lua
@@ -83,17 +83,8 @@ local function MasonInstall(package_specifiers, opts)
opts = opts or {}
local Package = require "mason-core.package"
local registry = require "mason-registry"
- local valid_packages = filter_valid_packages(package_specifiers)
local is_headless = #vim.api.nvim_list_uis() == 0
- if is_headless and #valid_packages ~= #package_specifiers then
- -- When executing in headless mode we don't allow any of the provided packages to be invalid.
- -- This is to avoid things like scripts silently not erroring even if they've provided one or more invalid packages.
- return vim.cmd [[1cq]]
- elseif #valid_packages == 0 then
- return
- end
-
local install_packages = _.map(function(pkg_specifier)
local package_name, version = Package.Parse(pkg_specifier)
local pkg = registry.get_package(package_name)
@@ -106,15 +97,25 @@ local function MasonInstall(package_specifiers, opts)
end)
if is_headless then
+ registry.refresh()
+ local valid_packages = filter_valid_packages(package_specifiers)
+ if #valid_packages ~= #package_specifiers then
+ -- When executing in headless mode we don't allow any of the provided packages to be invalid.
+ -- This is to avoid things like scripts silently not erroring even if they've provided one or more invalid packages.
+ return vim.cmd [[1cq]]
+ end
join_handles(install_packages(valid_packages))
else
local ui = require "mason.ui"
ui.open()
-- Important: We start installation of packages _after_ opening the UI. This gives the UI components a chance to
-- register the necessary event handlers in time, avoiding desynced state.
- install_packages(valid_packages)
- vim.schedule(function()
- ui.set_sticky_cursor "installing-section"
+ registry.refresh(function()
+ local valid_packages = filter_valid_packages(package_specifiers)
+ install_packages(valid_packages)
+ vim.schedule(function()
+ ui.set_sticky_cursor "installing-section"
+ end)
end)
end
end