From efdd73c0962cf46889d2e043efb892cf3ec432b7 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 7 Sep 2026 16:21:52 +0100 Subject: feat(watch): add on_error callback Problem: Watcher failures are reported inconsistently, and callers cannot detect when a watcher is no longer usable. Solution: Route startup and event failures and unexpected inotifywait exits through an optional on_error callback. Log to nvim-watch.log by default. Ignore disappearing child directories and exits caused by cancellation. Let LSP log failures and notify once per message, using INFO for missing roots and ERROR otherwise, without interrupting registration. AI-assisted --- runtime/lua/vim/_core/util.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/_core') diff --git a/runtime/lua/vim/_core/util.lua b/runtime/lua/vim/_core/util.lua index 08cbf17f04..133e5a7eeb 100644 --- a/runtime/lua/vim/_core/util.lua +++ b/runtime/lua/vim/_core/util.lua @@ -209,9 +209,11 @@ end --- @param name string Plugin name, e.g. "zip". --- @param msg string --- @param level? integer Level from |vim.log.levels|. Defaults to ERROR. -function M.notify(name, msg, level) +--- @param once? boolean Only show the message once. +function M.notify(name, msg, level, once) vim.schedule(function() - vim.notify(('%s: %s'):format(name, msg), level or vim.log.levels.ERROR) + local notify = once and vim.notify_once or vim.notify + notify(('%s: %s'):format(name, msg), level or vim.log.levels.ERROR) end) end -- cgit