diff options
| author | William Boman <william@redwill.se> | 2023-04-01 21:55:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-01 21:55:58 +0200 |
| commit | bdc5b36ee4124682e35bd59e0f162f0d0d09017f (patch) | |
| tree | ad79f66c14dea79938c07230f7a5c1129f544063 /lua | |
| parent | chore: migrate packages (#1163) (diff) | |
| download | mason-bdc5b36ee4124682e35bd59e0f162f0d0d09017f.tar mason-bdc5b36ee4124682e35bd59e0f162f0d0d09017f.tar.gz mason-bdc5b36ee4124682e35bd59e0f162f0d0d09017f.tar.bz2 mason-bdc5b36ee4124682e35bd59e0f162f0d0d09017f.tar.lz mason-bdc5b36ee4124682e35bd59e0f162f0d0d09017f.tar.xz mason-bdc5b36ee4124682e35bd59e0f162f0d0d09017f.tar.zst mason-bdc5b36ee4124682e35bd59e0f162f0d0d09017f.zip | |
feat(ui): display warning and error message if registry is not installed (#1164)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/mason-registry/sources/github.lua | 6 | ||||
| -rw-r--r-- | lua/mason/ui/colors.lua | 3 | ||||
| -rw-r--r-- | lua/mason/ui/components/header.lua | 72 | ||||
| -rw-r--r-- | lua/mason/ui/components/help/init.lua | 2 | ||||
| -rw-r--r-- | lua/mason/ui/instance.lua | 20 | ||||
| -rw-r--r-- | lua/mason/ui/palette.lua | 1 |
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, |
