From 6ca6f99e7689c68679e8f0a58b421545ff52931f Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 1 Nov 2022 00:24:40 +0100 Subject: [PATCH] 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 --- doc/nvim-tree-lua.txt | 15 +++++++ lua/nvim-tree.lua | 13 ++++-- lua/nvim-tree/actions/fs/copy-paste.lua | 17 +++---- lua/nvim-tree/actions/fs/create-file.lua | 9 ++-- lua/nvim-tree/actions/fs/remove-file.lua | 9 ++-- lua/nvim-tree/actions/fs/rename-file.lua | 7 +-- lua/nvim-tree/actions/fs/trash.lua | 9 ++-- lua/nvim-tree/actions/init.lua | 4 +- .../actions/tree-modifiers/expand-all.lua | 4 +- lua/nvim-tree/events.lua | 4 +- lua/nvim-tree/explorer/explore.lua | 3 +- lua/nvim-tree/explorer/reload.lua | 3 +- lua/nvim-tree/legacy.lua | 7 +-- lua/nvim-tree/log.lua | 2 +- lua/nvim-tree/marks/bulk-move.lua | 5 ++- lua/nvim-tree/notify.lua | 44 +++++++++++++++++++ lua/nvim-tree/renderer/components/git.lua | 4 +- lua/nvim-tree/utils.lua | 20 --------- lua/nvim-tree/watcher.lua | 7 +-- 19 files changed, 120 insertions(+), 66 deletions(-) create mode 100644 lua/nvim-tree/notify.lua diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 024ff02f..00f2d133 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -373,6 +373,9 @@ Subsequent calls to setup will replace the previous configuration. watcher = false, }, }, + notify = { + threshold = vim.log.levels.INFO, + }, } -- END_DEFAULT_OPTS < @@ -992,6 +995,18 @@ The filter can be cleared with the `F` key by default. Whether to filter folders or not. Type: `boolean`, Default: `true` +*nvim-tree.notify* +Configuration for notification. + + *nvim-tree.notify.threshold* + Specify minimum notification level, uses the values from |vim.log.levels| + Type: `enum`, Default: `vim.log.levels.INFO` + + `ERROR`: hard errors e.g. failure to read from the file system. + `WARNING`: non-fatal errors e.g. unable to system open a file. + `INFO:` information only e.g. file copy path confirmation. + `DEBUG:` not used. + *nvim-tree.log* Configuration for diagnostic logging. diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index b87a2e48..28c2edaf 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -640,6 +640,9 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS prefix = "[FILTER]: ", always_show_folders = true, }, + notify = { + threshold = vim.log.levels.INFO, + }, log = { enable = false, truncate = false, @@ -686,10 +689,11 @@ local function validate_options(conf) local override_typecheck = FIELD_OVERRIDE_TYPECHECK[k] or {} if def[k] == nil then -- option does not exist - invalid = string.format("unknown option: %s%s", prefix, k) + invalid = string.format("[NvimTree] unknown option: %s%s", prefix, k) elseif type(v) ~= type(def[k]) and not override_typecheck[type(v)] then -- option is of the wrong type and is not a function - invalid = string.format("invalid option: %s%s expected: %s actual: %s", prefix, k, type(def[k]), type(v)) + invalid = + string.format("[NvimTree] invalid option: %s%s expected: %s actual: %s", prefix, k, type(def[k]), type(v)) end if invalid then @@ -709,13 +713,13 @@ local function validate_options(conf) validate(conf, DEFAULT_OPTS, "") if msg then - utils.notify.warn(msg .. " | see :help nvim-tree-setup for available configuration options") + vim.notify_once(msg .. " | see :help nvim-tree-setup for available configuration options", vim.log.levels.WARN) end end function M.setup(conf) if vim.fn.has "nvim-0.7" == 0 then - utils.notify.warn "nvim-tree.lua requires Neovim 0.7 or higher" + vim.notify_once("nvim-tree.lua requires Neovim 0.7 or higher", vim.log.levels.WARN) return end @@ -742,6 +746,7 @@ function M.setup(conf) manage_netrw(opts.disable_netrw, opts.hijack_netrw) M.config = opts + require("nvim-tree.notify").setup(opts) require("nvim-tree.log").setup(opts) log.line("config", "default config + user") diff --git a/lua/nvim-tree/actions/fs/copy-paste.lua b/lua/nvim-tree/actions/fs/copy-paste.lua index 1fb4bc53..16ede80a 100644 --- a/lua/nvim-tree/actions/fs/copy-paste.lua +++ b/lua/nvim-tree/actions/fs/copy-paste.lua @@ -4,6 +4,7 @@ local lib = require "nvim-tree.lib" local log = require "nvim-tree.log" local utils = require "nvim-tree.utils" local core = require "nvim-tree.core" +local notify = require "nvim-tree.notify" local M = {} @@ -81,14 +82,14 @@ local function do_single_paste(source, dest, action_type, action_fn) dest_stats, errmsg, errcode = uv.fs_stat(dest) if not dest_stats and errcode ~= "ENOENT" then - utils.notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???")) + notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???")) return false, errmsg end local function on_process() success, errmsg = action_fn(source, dest) if not success then - utils.notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???")) + notify.error("Could not " .. action_type .. " " .. source .. " - " .. (errmsg or "???")) return false, errmsg end end @@ -122,11 +123,11 @@ local function add_to_clipboard(node, clip) for idx, _node in ipairs(clip) do if _node.absolute_path == node.absolute_path then table.remove(clip, idx) - return utils.notify.info(node.absolute_path .. " removed to clipboard.") + return notify.info(node.absolute_path .. " removed to clipboard.") end end table.insert(clip, node) - utils.notify.info(node.absolute_path .. " added to clipboard.") + notify.info(node.absolute_path .. " added to clipboard.") end function M.clear_clipboard() @@ -157,7 +158,7 @@ local function do_paste(node, action_type, action_fn) local stats, errmsg, errcode = uv.fs_stat(destination) if not stats and errcode ~= "ENOENT" then log.line("copy_paste", "do_paste fs_stat '%s' failed '%s'", destination, errmsg) - utils.notify.error("Could not " .. action_type .. " " .. destination .. " - " .. (errmsg or "???")) + notify.error("Could not " .. action_type .. " " .. destination .. " - " .. (errmsg or "???")) return end local is_dir = stats and stats.type == "directory" @@ -219,18 +220,18 @@ function M.print_clipboard() end end - return utils.notify.info(table.concat(content, "\n") .. "\n") + return notify.info(table.concat(content, "\n") .. "\n") end local function copy_to_clipboard(content) if M.use_system_clipboard == true then vim.fn.setreg("+", content) vim.fn.setreg('"', content) - return utils.notify.info(string.format("Copied %s to system clipboard!", content)) + return notify.info(string.format("Copied %s to system clipboard!", content)) else vim.fn.setreg('"', content) vim.fn.setreg("1", content) - return utils.notify.info(string.format("Copied %s to neovim clipboard!", content)) + return notify.info(string.format("Copied %s to neovim clipboard!", content)) end end diff --git a/lua/nvim-tree/actions/fs/create-file.lua b/lua/nvim-tree/actions/fs/create-file.lua index e4b167a6..ab3d27aa 100644 --- a/lua/nvim-tree/actions/fs/create-file.lua +++ b/lua/nvim-tree/actions/fs/create-file.lua @@ -5,13 +5,14 @@ local events = require "nvim-tree.events" local lib = require "nvim-tree.lib" local core = require "nvim-tree.core" local watch = require "nvim-tree.explorer.watch" +local notify = require "nvim-tree.notify" local M = {} local function create_and_notify(file) local ok, fd = pcall(uv.fs_open, file, "w", 420) if not ok then - utils.notify.error("Couldn't create file " .. file) + notify.error("Couldn't create file " .. file) return end uv.fs_close(fd) @@ -71,7 +72,7 @@ function M.fn(node) end if utils.file_exists(new_file_path) then - utils.notify.warn "Cannot create: file already exists" + notify.warn "Cannot create: file already exists" return end @@ -96,14 +97,14 @@ function M.fn(node) elseif not utils.file_exists(path_to_create) then local success = uv.fs_mkdir(path_to_create, 493) if not success then - utils.notify.error("Could not create folder " .. path_to_create) + notify.error("Could not create folder " .. path_to_create) is_error = true break end end end if not is_error then - utils.notify.info(new_file_path .. " was properly created") + notify.info(new_file_path .. " was properly created") end events._dispatch_folder_created(new_file_path) if M.enable_reload then diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index 3a94e31f..049f906e 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -5,6 +5,7 @@ local utils = require "nvim-tree.utils" local events = require "nvim-tree.events" local view = require "nvim-tree.view" local lib = require "nvim-tree.lib" +local notify = require "nvim-tree.notify" local M = {} @@ -44,7 +45,7 @@ end local function remove_dir(cwd) local handle = luv.fs_scandir(cwd) if type(handle) == "string" then - return utils.notify.error(handle) + return notify.error(handle) end while true do @@ -83,18 +84,18 @@ function M.fn(node) if node.nodes ~= nil and not node.link_to then local success = remove_dir(node.absolute_path) if not success then - return utils.notify.error("Could not remove " .. node.name) + return notify.error("Could not remove " .. node.name) end events._dispatch_folder_removed(node.absolute_path) else local success = luv.fs_unlink(node.absolute_path) if not success then - return utils.notify.error("Could not remove " .. node.name) + return notify.error("Could not remove " .. node.name) end events._dispatch_file_removed(node.absolute_path) clear_buffer(node.absolute_path) end - utils.notify.info(node.absolute_path .. " was properly removed.") + notify.info(node.absolute_path .. " was properly removed.") if M.enable_reload then require("nvim-tree.actions.reloaders.reloaders").reload_explorer() end diff --git a/lua/nvim-tree/actions/fs/rename-file.lua b/lua/nvim-tree/actions/fs/rename-file.lua index 6ca8cf83..6ed024fd 100644 --- a/lua/nvim-tree/actions/fs/rename-file.lua +++ b/lua/nvim-tree/actions/fs/rename-file.lua @@ -3,6 +3,7 @@ local uv = vim.loop local lib = require "nvim-tree.lib" local utils = require "nvim-tree.utils" local events = require "nvim-tree.events" +local notify = require "nvim-tree.notify" local M = {} @@ -12,15 +13,15 @@ end function M.rename(node, to) if utils.file_exists(to) then - utils.notify.warn(err_fmt(node.absolute_path, to, "file already exists")) + notify.warn(err_fmt(node.absolute_path, to, "file already exists")) return end local success, err = uv.fs_rename(node.absolute_path, to) if not success then - return utils.notify.warn(err_fmt(node.absolute_path, to, err)) + return notify.warn(err_fmt(node.absolute_path, to, err)) end - utils.notify.info(node.absolute_path .. " ➜ " .. to) + notify.info(node.absolute_path .. " ➜ " .. to) utils.rename_loaded_buffers(node.absolute_path, to) events._dispatch_node_renamed(node.absolute_path, to) end diff --git a/lua/nvim-tree/actions/fs/trash.lua b/lua/nvim-tree/actions/fs/trash.lua index a50133ab..fea8dad2 100644 --- a/lua/nvim-tree/actions/fs/trash.lua +++ b/lua/nvim-tree/actions/fs/trash.lua @@ -1,6 +1,7 @@ local a = vim.api local lib = require "nvim-tree.lib" +local notify = require "nvim-tree.notify" local M = { config = { @@ -43,13 +44,13 @@ function M.fn(node) M.config.trash.require_confirm = true end else - utils.notify.warn "Trash is currently a UNIX only feature!" + notify.warn "Trash is currently a UNIX only feature!" return end local binary = M.config.trash.cmd:gsub(" .*$", "") if vim.fn.executable(binary) == 0 then - utils.notify.warn(binary .. " is not executable.") + notify.warn(binary .. " is not executable.") return end @@ -71,7 +72,7 @@ function M.fn(node) if node.nodes ~= nil and not node.link_to then trash_path(function(_, rc) if rc ~= 0 then - utils.notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash") + notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash") return end events._dispatch_folder_removed(node.absolute_path) @@ -82,7 +83,7 @@ function M.fn(node) else trash_path(function(_, rc) if rc ~= 0 then - utils.notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash") + notify.warn("trash failed: " .. err_msg .. "; please see :help nvim-tree.trash") return end events._dispatch_file_removed(node.absolute_path) diff --git a/lua/nvim-tree/actions/init.lua b/lua/nvim-tree/actions/init.lua index d755a559..96b0c66c 100644 --- a/lua/nvim-tree/actions/init.lua +++ b/lua/nvim-tree/actions/init.lua @@ -4,7 +4,7 @@ local a = vim.api local log = require "nvim-tree.log" local view = require "nvim-tree.view" -local util = require "nvim-tree.utils" +local notify = require "nvim-tree.notify" -- BEGIN_DEFAULT_MAPPINGS local DEFAULT_MAPPINGS = { @@ -307,7 +307,7 @@ local function merge_mappings(user_mappings) if not is_empty(map.action) then M.custom_keypress_funcs[map.action] = map.action_cb else - util.notify.warn "action can't be empty if action_cb provided" + notify.warn "action can't be empty if action_cb provided" end end end diff --git a/lua/nvim-tree/actions/tree-modifiers/expand-all.lua b/lua/nvim-tree/actions/tree-modifiers/expand-all.lua index dcf1241b..04b95038 100644 --- a/lua/nvim-tree/actions/tree-modifiers/expand-all.lua +++ b/lua/nvim-tree/actions/tree-modifiers/expand-all.lua @@ -1,7 +1,7 @@ local core = require "nvim-tree.core" local renderer = require "nvim-tree.renderer" -local utils = require "nvim-tree.utils" local Iterator = require "nvim-tree.iterators.node-iterator" +local notify = require "nvim-tree.notify" local M = {} @@ -58,7 +58,7 @@ end function M.fn(base_node) local node = base_node.nodes and base_node or core.get_explorer() if gen_iterator()(node) then - utils.notify.warn("expansion iteration was halted after " .. M.MAX_FOLDER_DISCOVERY .. " discovered folders") + notify.warn("expansion iteration was halted after " .. M.MAX_FOLDER_DISCOVERY .. " discovered folders") end renderer.draw() end diff --git a/lua/nvim-tree/events.lua b/lua/nvim-tree/events.lua index 89010b73..c68b249c 100644 --- a/lua/nvim-tree/events.lua +++ b/lua/nvim-tree/events.lua @@ -1,4 +1,4 @@ -local utils = require "nvim-tree.utils" +local notify = require "nvim-tree.notify" local M = {} @@ -30,7 +30,7 @@ local function dispatch(event_name, payload) for _, handler in pairs(get_handlers(event_name)) do local success, error = pcall(handler, payload) if not success then - utils.notify.error("Handler for event " .. event_name .. " errored. " .. vim.inspect(error)) + notify.error("Handler for event " .. event_name .. " errored. " .. vim.inspect(error)) end end end diff --git a/lua/nvim-tree/explorer/explore.lua b/lua/nvim-tree/explorer/explore.lua index 7396024a..76e6cfc0 100644 --- a/lua/nvim-tree/explorer/explore.lua +++ b/lua/nvim-tree/explorer/explore.lua @@ -6,6 +6,7 @@ local common = require "nvim-tree.explorer.common" local sorters = require "nvim-tree.explorer.sorters" local filters = require "nvim-tree.explorer.filters" local live_filter = require "nvim-tree.live-filter" +local notify = require "nvim-tree.notify" local M = {} @@ -52,7 +53,7 @@ end local function get_dir_handle(cwd) local handle = uv.fs_scandir(cwd) if type(handle) == "string" then - utils.notify.error(handle) + notify.error(handle) return end return handle diff --git a/lua/nvim-tree/explorer/reload.lua b/lua/nvim-tree/explorer/reload.lua index 47c82d39..5e6e7c97 100644 --- a/lua/nvim-tree/explorer/reload.lua +++ b/lua/nvim-tree/explorer/reload.lua @@ -6,6 +6,7 @@ local common = require "nvim-tree.explorer.common" local filters = require "nvim-tree.explorer.filters" local sorters = require "nvim-tree.explorer.sorters" local live_filter = require "nvim-tree.live-filter" +local notify = require "nvim-tree.notify" local M = {} @@ -22,7 +23,7 @@ function M.reload(node, status) local cwd = node.link_to or node.absolute_path local handle = uv.fs_scandir(cwd) if type(handle) == "string" then - utils.notify.error(handle) + notify.error(handle) return end diff --git a/lua/nvim-tree/legacy.lua b/lua/nvim-tree/legacy.lua index c144ca06..159bbe05 100644 --- a/lua/nvim-tree/legacy.lua +++ b/lua/nvim-tree/legacy.lua @@ -1,4 +1,5 @@ local utils = require "nvim-tree.utils" +local notify = require "nvim-tree.notify" local M = {} @@ -292,12 +293,12 @@ end local function removed(opts) if opts.auto_close then - utils.notify.warn "auto close feature has been removed, see note in the README (tips & reminder section)" + notify.warn "auto close feature has been removed, see note in the README (tips & reminder section)" opts.auto_close = nil end if opts.focus_empty_on_setup then - utils.notify.warn "focus_empty_on_setup has been removed and will be replaced by a new startup configuration. Please remove this option. See https://bit.ly/3yJch2T" + notify.warn "focus_empty_on_setup has been removed and will be replaced by a new startup configuration. Please remove this option. See https://bit.ly/3yJch2T" end opts.focus_empty_on_setup = nil end @@ -312,7 +313,7 @@ function M.migrate_legacy_options(opts) end end if msg then - utils.notify.warn(msg) + notify.warn(msg) end -- silently move diff --git a/lua/nvim-tree/log.lua b/lua/nvim-tree/log.lua index af26238b..480dc63e 100644 --- a/lua/nvim-tree/log.lua +++ b/lua/nvim-tree/log.lua @@ -56,7 +56,7 @@ function M.setup(opts) if M.config.truncate then os.remove(M.path) end - require("nvim-tree.utils").notify.debug("nvim-tree.lua logging to " .. M.path) + require("nvim-tree.notify").debug("nvim-tree.lua logging to " .. M.path) end end diff --git a/lua/nvim-tree/marks/bulk-move.lua b/lua/nvim-tree/marks/bulk-move.lua index 1cdf4831..ee0e2e8b 100644 --- a/lua/nvim-tree/marks/bulk-move.lua +++ b/lua/nvim-tree/marks/bulk-move.lua @@ -2,12 +2,13 @@ local Marks = require "nvim-tree.marks" local Core = require "nvim-tree.core" local utils = require "nvim-tree.utils" local FsRename = require "nvim-tree.actions.fs.rename-file" +local notify = require "nvim-tree.notify" local M = {} function M.bulk_move() if #Marks.get_marks() == 0 then - utils.notify.warn "no bookmark to perform bulk move on, aborting." + notify.warn "no bookmark to perform bulk move on, aborting." return end @@ -17,7 +18,7 @@ function M.bulk_move() return end if vim.fn.filewritable(location) ~= 2 then - utils.notify.warn(location .. " is not writable, cannot move.") + notify.warn(location .. " is not writable, cannot move.") return end diff --git a/lua/nvim-tree/notify.lua b/lua/nvim-tree/notify.lua new file mode 100644 index 00000000..f52ffd39 --- /dev/null +++ b/lua/nvim-tree/notify.lua @@ -0,0 +1,44 @@ +local M = {} + +local config = { + threshold = vim.log.levels.INFO, +} + +local modes = { + { name = "trace", level = vim.log.levels.TRACE }, + { name = "debug", level = vim.log.levels.DEBUG }, + { name = "info", level = vim.log.levels.INFO }, + { name = "warn", level = vim.log.levels.WARN }, + { name = "error", level = vim.log.levels.ERROR }, +} + +do + local has_notify, notify_plugin = pcall(require, "notify") + + local dispatch = function(level, msg) + if level < config.threshold then + return + end + + vim.schedule(function() + if has_notify and notify_plugin then + notify_plugin(msg, level, { title = "NvimTree" }) + else + vim.notify("[NvimTree] " .. msg, level) + end + end) + end + + for _, x in ipairs(modes) do + M[x.name] = function(msg, ...) + return dispatch(x.level, msg, ...) + end + end +end + +function M.setup(opts) + opts = opts or {} + config.threshold = opts.notify.threshold or vim.log.levels.INFO +end + +return M diff --git a/lua/nvim-tree/renderer/components/git.lua b/lua/nvim-tree/renderer/components/git.lua index 1b98a1b2..644e06c3 100644 --- a/lua/nvim-tree/renderer/components/git.lua +++ b/lua/nvim-tree/renderer/components/git.lua @@ -1,4 +1,4 @@ -local utils = require "nvim-tree.utils" +local notify = require "nvim-tree.notify" local M = { SIGN_GROUP = "NvimTreeGitSigns", @@ -68,7 +68,7 @@ end local function nil_() end local function warn_status(git_status) - utils.notify.warn( + notify.warn( 'Unrecognized git state "' .. git_status .. '". Please open up an issue on https://github.com/nvim-tree/nvim-tree.lua/issues with this message.' diff --git a/lua/nvim-tree/utils.lua b/lua/nvim-tree/utils.lua index e81327ff..2946aa25 100644 --- a/lua/nvim-tree/utils.lua +++ b/lua/nvim-tree/utils.lua @@ -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 diff --git a/lua/nvim-tree/watcher.lua b/lua/nvim-tree/watcher.lua index 25af2059..df29e7bc 100644 --- a/lua/nvim-tree/watcher.lua +++ b/lua/nvim-tree/watcher.lua @@ -1,4 +1,5 @@ local uv = vim.loop +local notify = require "nvim-tree.notify" local log = require "nvim-tree.log" local utils = require "nvim-tree.utils" @@ -47,7 +48,7 @@ function Event:start() self._fs_event, _, name = uv.new_fs_event() if not self._fs_event then self._fs_event = nil - utils.notify.warn(string.format("Could not initialize an fs_event watcher for path %s : %s", self._path, name)) + notify.warn(string.format("Could not initialize an fs_event watcher for path %s : %s", self._path, name)) return false end @@ -64,7 +65,7 @@ function Event:start() rc, _, name = self._fs_event:start(self._path, FS_EVENT_FLAGS, event_cb) if rc ~= 0 then - utils.notify.warn(string.format("Could not start the fs_event watcher for path %s : %s", self._path, name)) + notify.warn(string.format("Could not start the fs_event watcher for path %s : %s", self._path, name)) return false end @@ -88,7 +89,7 @@ function Event:destroy() if self._fs_event then local rc, _, name = self._fs_event:stop() if rc ~= 0 then - utils.notify.warn(string.format("Could not stop the fs_event watcher for path %s : %s", self._path, name)) + notify.warn(string.format("Could not stop the fs_event watcher for path %s : %s", self._path, name)) end self._fs_event = nil end