feat(notify): add notify.threshold (#1693)

* feat: configurable notification level

add `notify.threshold` to setup opts

* feat: configurable notification level: add threshold example doc

* feat: configurable notification level: log always comes last

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
kylo252
2022-11-01 00:24:40 +01:00
committed by GitHub
parent ada2c6441d
commit 6ca6f99e76
19 changed files with 120 additions and 66 deletions

View File

@@ -1,5 +1,3 @@
local has_notify, notify = pcall(require, "notify")
local a = vim.api
local uv = vim.loop
@@ -16,24 +14,6 @@ function M.path_to_matching_str(path)
return path:gsub("(%-)", "(%%-)"):gsub("(%.)", "(%%.)"):gsub("(%_)", "(%%_)")
end
local function notify_level(level)
return function(msg)
vim.schedule(function()
if has_notify then
notify(msg, level, { title = "NvimTree" })
else
vim.notify("[NvimTree] " .. msg, level)
end
end)
end
end
M.notify = {}
M.notify.warn = notify_level(vim.log.levels.WARN)
M.notify.error = notify_level(vim.log.levels.ERROR)
M.notify.info = notify_level(vim.log.levels.INFO)
M.notify.debug = notify_level(vim.log.levels.DEBUG)
function M.str_find(haystack, needle)
return vim.fn.stridx(haystack, needle) ~= -1
end