aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-03-23 18:35:49 +0100
committerGitHub <noreply@github.com>2023-03-23 18:35:49 +0100
commit9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1 (patch)
treea68b84df3d6449fbe60785a9e6198f8f8524f9f5 /lua
parentchore: migrate lua-language-server (#1127) (diff)
downloadmason-9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1.tar
mason-9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1.tar.gz
mason-9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1.tar.bz2
mason-9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1.tar.lz
mason-9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1.tar.xz
mason-9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1.tar.zst
mason-9f4e06029b1d8cd3bb4438f6b3de6d5c42d2d8d1.zip
fix(api): refresh registry before installing packages in :MasonInstall (#1128)
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