aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/mason-registry/sources/github.lua6
-rw-r--r--lua/mason/ui/colors.lua3
-rw-r--r--lua/mason/ui/components/header.lua72
-rw-r--r--lua/mason/ui/components/help/init.lua2
-rw-r--r--lua/mason/ui/instance.lua20
-rw-r--r--lua/mason/ui/palette.lua1
6 files changed, 82 insertions, 22 deletions
diff --git a/lua/mason-registry/sources/github.lua b/lua/mason-registry/sources/github.lua
index 704c78d8..7920e0d7 100644
--- a/lua/mason-registry/sources/github.lua
+++ b/lua/mason-registry/sources/github.lua
@@ -123,7 +123,11 @@ function GitHubRegistrySource:install()
if version == nil then
log.trace("Resolving latest version for registry", self)
---@type GitHubRelease
- local release = try(providers.github.get_latest_release(self.spec.repo))
+ local release = try(
+ providers.github
+ .get_latest_release(self.spec.repo)
+ :map_err(_.always "Failed to fetch latest registry version from GitHub API.")
+ )
version = release.tag_name
log.trace("Resolved latest registry version", self, version)
end
diff --git a/lua/mason/ui/colors.lua b/lua/mason/ui/colors.lua
index 7cb1ed92..cdae3f28 100644
--- a/lua/mason/ui/colors.lua
+++ b/lua/mason/ui/colors.lua
@@ -17,7 +17,8 @@ local hl_groups = {
MasonMutedBlock = { bg = "#888888", fg = "#222222", default = true },
MasonMutedBlockBold = { bg = "#888888", fg = "#222222", bold = true, default = true },
- MasonError = { fg = "#f44747", default = true },
+ MasonError = { link = "ErrorMsg", default = true },
+ MasonWarning = { link = "WarningMsg", default = true },
MasonHeading = { bold = true, default = true },
}
diff --git a/lua/mason/ui/components/header.lua b/lua/mason/ui/components/header.lua
index 484753ae..fc2aeac6 100644
--- a/lua/mason/ui/components/header.lua
+++ b/lua/mason/ui/components/header.lua
@@ -1,22 +1,62 @@
local Ui = require "mason-core.ui"
+local _ = require "mason-core.functional"
local p = require "mason.ui.palette"
+local settings = require "mason.settings"
---@param state InstallerUiState
return function(state)
- return Ui.CascadingStyleNode({ "CENTERED" }, {
- Ui.HlTextNode {
- Ui.When(state.view.is_showing_help, {
- p.header_secondary(" " .. state.header.title_prefix .. " mason.nvim "),
- p.none((" "):rep(#state.header.title_prefix + 1)),
- }, {
- p.header " mason.nvim ",
- }),
- Ui.When(
- state.view.is_showing_help,
- { p.none " press ", p.highlight_secondary "g?", p.none " for package list" },
- { p.none "press ", p.highlight "g?", p.none " for help" }
- ),
- { p.Comment "https://github.com/williamboman/mason.nvim" },
- },
- })
+ local uninstalled_registries = _.filter(_.prop_eq("is_installed", false), state.info.registries)
+
+ return Ui.Node {
+ Ui.CascadingStyleNode({ "CENTERED" }, {
+ Ui.HlTextNode {
+ Ui.When(state.view.is_showing_help, {
+ p.header_secondary(" " .. state.header.title_prefix .. " mason.nvim "),
+ p.none((" "):rep(#state.header.title_prefix + 1)),
+ }, {
+ p.header " mason.nvim ",
+ }),
+ Ui.When(
+ state.view.is_showing_help,
+ { p.none " press ", p.highlight_secondary "g?", p.none " for package list" },
+ { p.none "press ", p.highlight "g?", p.none " for help" }
+ ),
+ { p.Comment "https://github.com/williamboman/mason.nvim" },
+ },
+ }),
+ Ui.When(not state.packages.new_versions_check.is_checking and #uninstalled_registries > 0, function()
+ return Ui.CascadingStyleNode({ "INDENT" }, {
+ Ui.EmptyLine(),
+ Ui.HlTextNode {
+ {
+ p.warning "Uninstalled registries",
+ },
+ {
+ p.Comment "Packages from the following registries are unavailable. Press ",
+ p.highlight(settings.current.ui.keymaps.check_outdated_packages),
+ p.Comment " to install.",
+ },
+ unpack(_.map(function(registry)
+ return { p.none(" - " .. registry.name) }
+ end, uninstalled_registries)),
+ },
+ Ui.EmptyLine(),
+ })
+ end),
+ Ui.When(
+ not state.packages.new_versions_check.is_checking and state.info.registry_update_error,
+ Ui.CascadingStyleNode({ "INDENT" }, {
+ Ui.HlTextNode {
+ {
+ p.error "Registry installation failed with the following error:",
+ },
+ {
+ p.none " ",
+ p.Comment(state.info.registry_update_error),
+ },
+ },
+ Ui.EmptyLine(),
+ })
+ ),
+ }
end
diff --git a/lua/mason/ui/components/help/init.lua b/lua/mason/ui/components/help/init.lua
index 4ef2759a..0b4a57a6 100644
--- a/lua/mason/ui/components/help/init.lua
+++ b/lua/mason/ui/components/help/init.lua
@@ -76,7 +76,7 @@ local function GenericHelp(state)
p.muted "Packages are sourced from the following registries:",
},
unpack(_.map(function(registry)
- return { p.none(" - " .. registry) }
+ return { p.none(" - " .. registry.name) }
end, state.info.registries)),
},
Ui.EmptyLine(),
diff --git a/lua/mason/ui/instance.lua b/lua/mason/ui/instance.lua
index 17843aea..6e2b8b23 100644
--- a/lua/mason/ui/instance.lua
+++ b/lua/mason/ui/instance.lua
@@ -59,8 +59,10 @@ local INITIAL_STATE = {
info = {
---@type string | nil
used_disk_space = nil,
- ---@type string[]
+ ---@type { name: string, is_installed: boolean }[]
registries = {},
+ ---@type string?
+ registry_update_error = nil,
},
view = {
is_showing_help = false,
@@ -475,7 +477,16 @@ local function check_new_visible_package_versions()
state.packages.new_versions_check.percentage_complete = 0
end)
- a.wait(registry.update)
+ do
+ local success, err = a.wait(registry.update)
+ mutate_state(function(state)
+ if not success then
+ state.info.registry_update_error = tostring(err)
+ else
+ state.info.registry_update_error = nil
+ end
+ end)
+ end
local sem = Semaphore.new(5)
a.wait_all(_.map(function(package)
@@ -655,7 +666,10 @@ end
local function update_registry_info()
local registries = {}
for source in require("mason-registry.sources").iter { include_uninstalled = true } do
- table.insert(registries, source:get_display_name())
+ table.insert(registries, {
+ name = source:get_display_name(),
+ is_installed = source:is_installed(),
+ })
end
mutate_state(function(state)
state.info.registries = registries
diff --git a/lua/mason/ui/palette.lua b/lua/mason/ui/palette.lua
index 4225a905..41bd87e2 100644
--- a/lua/mason/ui/palette.lua
+++ b/lua/mason/ui/palette.lua
@@ -20,6 +20,7 @@ M.highlight_block_secondary = hl "MasonHighlightBlockSecondary"
M.highlight_block_bold_secondary = hl "MasonHighlightBlockBoldSecondary"
M.highlight_secondary = hl "MasonHighlightSecondary"
M.error = hl "MasonError"
+M.warning = hl "MasonWarning"
M.heading = hl "MasonHeading"
setmetatable(M, {