From 8a0524d6bd8983786ebbc8498f92466278101e39 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 7 Oct 2023 15:17:54 +1100 Subject: [PATCH] chore: stylua column width 120 -> 140, tidy --- .stylua.toml | 2 +- lua/nvim-tree/actions/node/open-file.lua | 8 +------- lua/nvim-tree/actions/node/system-open.lua | 18 +++++++----------- lua/nvim-tree/diagnostics.lua | 6 +----- lua/nvim-tree/git/runner.lua | 8 +------- lua/nvim-tree/modified.lua | 5 +---- lua/nvim-tree/renderer/components/git.lua | 6 +----- lua/nvim-tree/watcher.lua | 15 +++++---------- 8 files changed, 18 insertions(+), 50 deletions(-) diff --git a/.stylua.toml b/.stylua.toml index ee662482..e9636bd0 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -1,4 +1,4 @@ -column_width = 140 +column_width = 160 line_endings = "Unix" indent_type = "Spaces" indent_width = 2 diff --git a/lua/nvim-tree/actions/node/open-file.lua b/lua/nvim-tree/actions/node/open-file.lua index 0add9560..080c9240 100644 --- a/lua/nvim-tree/actions/node/open-file.lua +++ b/lua/nvim-tree/actions/node/open-file.lua @@ -62,13 +62,7 @@ local function pick_win_id() end if #M.window_picker.chars < #selectable then - notify.error( - string.format( - "More windows (%d) than actions.open_file.window_picker.chars (%d) - please add more.", - #selectable, - #M.window_picker.chars - ) - ) + notify.error(string.format("More windows (%d) than actions.open_file.window_picker.chars (%d) - please add more.", #selectable, #M.window_picker.chars)) return nil end diff --git a/lua/nvim-tree/actions/node/system-open.lua b/lua/nvim-tree/actions/node/system-open.lua index a5ff2bd1..44884f6e 100644 --- a/lua/nvim-tree/actions/node/system-open.lua +++ b/lua/nvim-tree/actions/node/system-open.lua @@ -16,18 +16,14 @@ function M.fn(node) stderr = vim.loop.new_pipe(false), } table.insert(process.args, node.link_to or node.absolute_path) - process.handle, process.pid = vim.loop.spawn( - process.cmd, - { args = process.args, stdio = { nil, nil, process.stderr }, detached = true }, - function(code) - process.stderr:read_stop() - process.stderr:close() - process.handle:close() - if code ~= 0 then - notify.warn(string.format("system_open failed with return code %d: %s", code, process.errors)) - end + process.handle, process.pid = vim.loop.spawn(process.cmd, { args = process.args, stdio = { nil, nil, process.stderr }, detached = true }, function(code) + process.stderr:read_stop() + process.stderr:close() + process.handle:close() + if code ~= 0 then + notify.warn(string.format("system_open failed with return code %d: %s", code, process.errors)) end - ) + end) table.remove(process.args) if not process.handle then notify.warn(string.format("system_open failed to spawn command '%s': %s", process.cmd, process.pid)) diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index 22463319..16633f91 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -95,11 +95,7 @@ function M.update() for line, node in pairs(nodes_by_line) do local nodepath = utils.canonical_path(node.absolute_path) log.line("diagnostics", " %d checking nodepath '%s'", line, nodepath) - if - M.show_on_dirs - and vim.startswith(bufpath:gsub("\\", "/"), nodepath:gsub("\\", "/") .. "/") - and (not node.open or M.show_on_open_dirs) - then + if M.show_on_dirs and vim.startswith(bufpath:gsub("\\", "/"), nodepath:gsub("\\", "/") .. "/") and (not node.open or M.show_on_open_dirs) then log.line("diagnostics", " matched fold node '%s'", node.absolute_path) node.diag_status = severity elseif nodepath == bufpath then diff --git a/lua/nvim-tree/git/runner.lua b/lua/nvim-tree/git/runner.lua index 008ebc46..aa93f530 100644 --- a/lua/nvim-tree/git/runner.lua +++ b/lua/nvim-tree/git/runner.lua @@ -156,13 +156,7 @@ function Runner:_finalise(opts) log.line("git", "job timed out %s %s", opts.toplevel, opts.path) timeouts = timeouts + 1 if timeouts == MAX_TIMEOUTS then - notify.warn( - string.format( - "%d git jobs have timed out after %dms, disabling git integration. Try increasing git.timeout", - timeouts, - opts.timeout - ) - ) + notify.warn(string.format("%d git jobs have timed out after %dms, disabling git integration. Try increasing git.timeout", timeouts, opts.timeout)) require("nvim-tree.git").disable_git_integration() end elseif self.rc ~= 0 then diff --git a/lua/nvim-tree/modified.lua b/lua/nvim-tree/modified.lua index 51025e1b..d4df3bd6 100644 --- a/lua/nvim-tree/modified.lua +++ b/lua/nvim-tree/modified.lua @@ -26,10 +26,7 @@ end ---@param node table ---@return boolean function M.is_modified(node) - return M.config.enable - and M._record[node.absolute_path] - and (not node.nodes or M.config.show_on_dirs) - and (not node.open or M.config.show_on_open_dirs) + return M.config.enable and M._record[node.absolute_path] and (not node.nodes or M.config.show_on_dirs) and (not node.open or M.config.show_on_open_dirs) end ---@param opts table diff --git a/lua/nvim-tree/renderer/components/git.lua b/lua/nvim-tree/renderer/components/git.lua index 977031fd..468a9ee5 100644 --- a/lua/nvim-tree/renderer/components/git.lua +++ b/lua/nvim-tree/renderer/components/git.lua @@ -94,11 +94,7 @@ end local function nil_() end local function warn_status(git_status) - 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.' - ) + 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.') end ---@param node table diff --git a/lua/nvim-tree/watcher.lua b/lua/nvim-tree/watcher.lua index efa52469..1693aa0f 100644 --- a/lua/nvim-tree/watcher.lua +++ b/lua/nvim-tree/watcher.lua @@ -73,14 +73,10 @@ function Event:start() rc, _, name = self._fs_event:start(self._path, FS_EVENT_FLAGS, event_cb) if rc ~= 0 then - local warning = string.format("Could not start the fs_event watcher for path %s : %s", self._path, name) if name == "EMFILE" then - M.disable_watchers( - warning, - "Please see https://github.com/nvim-tree/nvim-tree.lua/wiki/Troubleshooting#could-not-start-fs_event-for-path--emfile" - ) + M.disable_watchers "fs.inotify.max_user_watches exceeded, see https://github.com/nvim-tree/nvim-tree.lua/wiki/Troubleshooting" else - notify.warn(warning) + notify.warn(string.format("Could not start the fs_event watcher for path %s : %s", self._path, name)) end return false end @@ -164,10 +160,9 @@ end M.Watcher = Watcher --- Permanently disable watchers and purge all state following a catastrophic error. ---- @param warning string ---- @param detail string -function M.disable_watchers(warning, detail) - notify.warn(string.format("%s Disabling watchers: %s", warning, detail)) +--- @param msg string +function M.disable_watchers(msg) + notify.warn(string.format("Disabling watchers: %s", msg)) M.config.filesystem_watchers.enable = false require("nvim-tree").purge_all_state() end