Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quiet Mode #2

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ local DEFAULT_SETTINGS = {
-- This setting has no relation with the `ensure_installed` setting.
---@type boolean
automatic_installation = true,

-- Disables warning notifications about misconfigurations such as invalid linter entries and incorrect plugin load order.
quiet_mode = false,
}
```

Expand Down
3 changes: 2 additions & 1 deletion lua/mason-nvim-lint/auto_install.lua
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lua/mason-nvim-lint/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions lua/mason-nvim-lint/install.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local registry = require "mason-registry"
local settings = require "mason-nvim-lint.settings"

local M = {}

Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions lua/mason-nvim-lint/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ local DEFAULT_SETTINGS = {
-- This setting has no relation with the `ensure_installed` setting.
---@type boolean
automatic_installation = true,

-- Disables warning notifications about misconfigurations such as invalid linter entries and incorrect plugin load order.
quiet_mode = false,
}

M._DEFAULT_SETTINGS = DEFAULT_SETTINGS
Expand Down