Skip to content

Commit

Permalink
feat: added Filter.cond to conditionally use a route
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 19, 2022
1 parent 7dac8ce commit 29a2e05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lua/noice/message/filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ local M = {}
---@field mode? string
---@field not? NoiceFilter
---@field warning? boolean
---@field cond? fun(message:NoiceMessage):boolean

-----@type table<string, NoiceFilterFun>
M.filters = {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lua/noice/view/backend/notify_send.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29a2e05

Please sign in to comment.