From 50f121d49a1e7786aae513063f721cdce6a2ef2e Mon Sep 17 00:00:00 2001 From: David Dean Date: Fri, 23 Feb 2024 23:18:11 -0600 Subject: [PATCH 1/2] Add quiet mode --- README.md | 3 +++ lua/mason-nvim-lint/auto_install.lua | 3 ++- lua/mason-nvim-lint/init.lua | 2 +- lua/mason-nvim-lint/install.lua | 17 ++++++++++------- lua/mason-nvim-lint/settings.lua | 3 +++ 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3a9c656..3f29d30 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ local DEFAULT_SETTINGS = { -- This setting has no relation with the `ensure_installed` setting. ---@type boolean automatic_installation = true, + + -- Disables warnings about unavailable linters + quiet_mode = false, } ``` diff --git a/lua/mason-nvim-lint/auto_install.lua b/lua/mason-nvim-lint/auto_install.lua index a13f329..90ad56b 100644 --- a/lua/mason-nvim-lint/auto_install.lua +++ b/lua/mason-nvim-lint/auto_install.lua @@ -1,6 +1,7 @@ local registry = require "mason-registry" local nvim_lint = require "lint" local mapping = require "mason-nvim-lint.mapping" +local settings = require "mason-nvim-lint.settings" --@return unknown_linters string[] local function auto_install() @@ -17,7 +18,7 @@ local function auto_install() end end - if #unknown_linters > 0 then + if #unknown_linters > 0 and not settings.current.quiet_mode then vim.notify( ("Linters [%s] are absent in the mason's registry. Please, install them manually and remove from configuration.") :format(table.concat(unknown_linters, ", ")), vim.log.levels.WARN) diff --git a/lua/mason-nvim-lint/init.lua b/lua/mason-nvim-lint/init.lua index 391753a..e044727 100644 --- a/lua/mason-nvim-lint/init.lua +++ b/lua/mason-nvim-lint/init.lua @@ -8,7 +8,7 @@ local function check_and_notify_bad_setup_order() local nvim_lint_ok, nvim_lint = pcall(require, "lint") local is_bad_order = not mason_ok or mason.has_setup == false or not nvim_lint_ok local impacts_functionality = not mason_ok or #settings.current.ensure_installed > 0 - if is_bad_order and impacts_functionality then + if is_bad_order and impacts_functionality and not settings.current.quiet_mode then vim.notify( "mason.nvim has not been set up. Make sure to set up 'mason' and 'nvim-lint' before 'mason-nvim-lint'. :h mason-nvim-lint-quickstart", vim.log.levels.WARN diff --git a/lua/mason-nvim-lint/install.lua b/lua/mason-nvim-lint/install.lua index 7ee9148..eb185ba 100644 --- a/lua/mason-nvim-lint/install.lua +++ b/lua/mason-nvim-lint/install.lua @@ -1,4 +1,5 @@ local registry = require "mason-registry" +local settings = require "mason-nvim-lint.settings" local M = {} @@ -52,13 +53,15 @@ function M.try_install(mason_linter_identifier) end ) :if_not_present(function() - vim.notify( - ("[mason-nvim-lint] Linter %q is not a valid entry in ensure_installed. Make sure to only provide valid linter names.") - :format( - package_name - ), - vim.log.levels.WARN - ) + if not settings.current.quiet_mode then + vim.notify( + ("[mason-nvim-lint] Linter %q is not a valid entry in ensure_installed. Make sure to only provide valid linter names.") + :format( + package_name + ), + vim.log.levels.WARN + ) + end end) end diff --git a/lua/mason-nvim-lint/settings.lua b/lua/mason-nvim-lint/settings.lua index b61778a..0c49c76 100644 --- a/lua/mason-nvim-lint/settings.lua +++ b/lua/mason-nvim-lint/settings.lua @@ -13,6 +13,9 @@ local DEFAULT_SETTINGS = { -- This setting has no relation with the `ensure_installed` setting. ---@type boolean automatic_installation = true, + + -- Disables warnings about unavailable linters + quiet_mode = false, } M._DEFAULT_SETTINGS = DEFAULT_SETTINGS From 0e5cd40f589259ac0c41a613796938593722d431 Mon Sep 17 00:00:00 2001 From: David Dean Date: Fri, 23 Feb 2024 23:48:45 -0600 Subject: [PATCH 2/2] improve comment --- README.md | 2 +- lua/mason-nvim-lint/settings.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f29d30..a6fdd9e 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ local DEFAULT_SETTINGS = { ---@type boolean automatic_installation = true, - -- Disables warnings about unavailable linters + -- Disables warning notifications about misconfigurations such as invalid linter entries and incorrect plugin load order. quiet_mode = false, } ``` diff --git a/lua/mason-nvim-lint/settings.lua b/lua/mason-nvim-lint/settings.lua index 0c49c76..22b2360 100644 --- a/lua/mason-nvim-lint/settings.lua +++ b/lua/mason-nvim-lint/settings.lua @@ -14,7 +14,7 @@ local DEFAULT_SETTINGS = { ---@type boolean automatic_installation = true, - -- Disables warnings about unavailable linters + -- Disables warning notifications about misconfigurations such as invalid linter entries and incorrect plugin load order. quiet_mode = false, }