From 7ca1e3208235a4a6157a5bf7f00810720b924507 Mon Sep 17 00:00:00 2001 From: Kasper van der Heijden Date: Tue, 9 Apr 2024 23:13:21 +0200 Subject: [PATCH 1/3] (feat): add option to ignore non-installed languages in the healthcheck --- lua/mason/health.lua | 8 ++++++-- lua/mason/settings.lua | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lua/mason/health.lua b/lua/mason/health.lua index b8680ad4a..53453779c 100644 --- a/lua/mason/health.lua +++ b/lua/mason/health.lua @@ -59,8 +59,12 @@ local function check(opts) report_ok(("%s: `%s`"):format(opts.name, version or "Ok")) end):on_failure(function(err) - local report = opts.relaxed and report_warn or report_error - report(("%s: not available"):format(opts.name), opts.advice or { tostring(err) }) + if settings.current.health.ignore[opts.name] then + report_ok(("%s: not available (SKIPPED)"):format(opts.name)) + else + local report = opts.relaxed and report_warn or report_error + report(("%s: not available"):format(opts.name), opts.advice or { tostring(err) }) + end end) permit:forget() end diff --git a/lua/mason/settings.lua b/lua/mason/settings.lua index 56fbcfb9f..dfafd07ee 100644 --- a/lua/mason/settings.lua +++ b/lua/mason/settings.lua @@ -137,6 +137,10 @@ local DEFAULT_SETTINGS = { toggle_help = "g?", }, }, + + health = { + ignore = {}, + }, } M._DEFAULT_SETTINGS = DEFAULT_SETTINGS From 9c5055166c987a4973febcdff95194234e2aea6f Mon Sep 17 00:00:00 2001 From: Kasper van der Heijden Date: Wed, 10 Apr 2024 09:52:00 +0200 Subject: [PATCH 2/3] Change wording to match intention --- lua/mason/health.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/mason/health.lua b/lua/mason/health.lua index 53453779c..560ea8b1f 100644 --- a/lua/mason/health.lua +++ b/lua/mason/health.lua @@ -60,7 +60,7 @@ local function check(opts) report_ok(("%s: `%s`"):format(opts.name, version or "Ok")) end):on_failure(function(err) if settings.current.health.ignore[opts.name] then - report_ok(("%s: not available (SKIPPED)"):format(opts.name)) + report_ok(("%s: not available (ignored)"):format(opts.name)) else local report = opts.relaxed and report_warn or report_error report(("%s: not available"):format(opts.name), opts.advice or { tostring(err) }) From 41828a02bd3d38e8f0f4b82cedeaf56054c9efa1 Mon Sep 17 00:00:00 2001 From: Kasper van der Heijden Date: Wed, 10 Apr 2024 10:00:11 +0200 Subject: [PATCH 3/3] Update readme. Expect array table instead --- README.md | 4 ++++ lua/mason/health.lua | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e33b653c..ff312f30b 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,10 @@ local DEFAULT_SETTINGS = { toggle_help = "g?", }, }, + + health = { + ignore = {}, + }, } ``` diff --git a/lua/mason/health.lua b/lua/mason/health.lua index 560ea8b1f..eba111a5e 100644 --- a/lua/mason/health.lua +++ b/lua/mason/health.lua @@ -59,7 +59,7 @@ local function check(opts) report_ok(("%s: `%s`"):format(opts.name, version or "Ok")) end):on_failure(function(err) - if settings.current.health.ignore[opts.name] then + if vim.tbl_contains(settings.current.health.ignore, opts.name) then report_ok(("%s: not available (ignored)"):format(opts.name)) else local report = opts.relaxed and report_warn or report_error