From 29a2e052d2653443716a8eece89300e9b36b5f2a Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 19 Dec 2022 15:38:34 +0100 Subject: [PATCH] feat: added `Filter.cond` to conditionally use a route --- lua/noice/message/filter.lua | 4 ++++ lua/noice/view/backend/notify_send.lua | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/noice/message/filter.lua b/lua/noice/message/filter.lua index 4fc2302..b766768 100644 --- a/lua/noice/message/filter.lua +++ b/lua/noice/message/filter.lua @@ -27,6 +27,7 @@ local M = {} ---@field mode? string ---@field not? NoiceFilter ---@field warning? boolean +---@field cond? fun(message:NoiceMessage):boolean -----@type table M.filters = { @@ -38,6 +39,9 @@ M.filters = { ---@cast message NoiceMessage return has == Manager.has(message, { history = true }) end, + cond = function(message, cond) + return cond(message) + end, mode = function(_, mode) return vim.api.nvim_get_mode().mode:find(mode) end, diff --git a/lua/noice/view/backend/notify_send.lua b/lua/noice/view/backend/notify_send.lua index 7a3e16c..d1e822c 100644 --- a/lua/noice/view/backend/notify_send.lua +++ b/lua/noice/view/backend/notify_send.lua @@ -52,7 +52,7 @@ end ---@param level? NotifyLevel|number function NotifySendView:get_urgency(level) if level then - local l = type(level) == "number" and level or vim.log.levels[level:lower()] + local l = type(level) == "number" and level or vim.log.levels[level:lower()] or vim.log.levels.INFO if l <= 1 then return "low" end