From dfe6a54b067682d69c58f793424f4d3813ecec27 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Sat, 13 Jul 2024 16:51:40 +0200 Subject: [PATCH 1/8] refactor: multi instance nvim-tree.explorer.sorters --- lua/nvim-tree/explorer/explore.lua | 5 +- lua/nvim-tree/explorer/reload.lua | 5 +- lua/nvim-tree/explorer/sorters.lua | 161 ++++++++++++++++------------- 3 files changed, 93 insertions(+), 78 deletions(-) diff --git a/lua/nvim-tree/explorer/explore.lua b/lua/nvim-tree/explorer/explore.lua index 8cb4bc4a350..14e1ecc6944 100644 --- a/lua/nvim-tree/explorer/explore.lua +++ b/lua/nvim-tree/explorer/explore.lua @@ -2,7 +2,7 @@ local utils = require "nvim-tree.utils" local builders = require "nvim-tree.explorer.node-builders" local explorer_node = require "nvim-tree.explorer.node" local git = require "nvim-tree.git" -local sorters = require "nvim-tree.explorer.sorters" +local Sorters = require "nvim-tree.explorer.sorters" local live_filter = require "nvim-tree.live-filter" local log = require "nvim-tree.log" @@ -82,7 +82,7 @@ function M.explore(node, status, parent) return ns end - sorters.sort(node.nodes) + M.sorters:sort(node.nodes) live_filter.apply_filter(node) log.profile_end(profile) @@ -90,6 +90,7 @@ function M.explore(node, status, parent) end function M.setup(opts) + M.sorters = Sorters:new(opts) M.config = opts.renderer end diff --git a/lua/nvim-tree/explorer/reload.lua b/lua/nvim-tree/explorer/reload.lua index 3243861ea6d..56de75e535a 100644 --- a/lua/nvim-tree/explorer/reload.lua +++ b/lua/nvim-tree/explorer/reload.lua @@ -1,7 +1,7 @@ local utils = require "nvim-tree.utils" local builders = require "nvim-tree.explorer.node-builders" local explorer_node = require "nvim-tree.explorer.node" -local sorters = require "nvim-tree.explorer.sorters" +local Sorters = require "nvim-tree.explorer.sorters" local live_filter = require "nvim-tree.live-filter" local git = require "nvim-tree.git" local log = require "nvim-tree.log" @@ -165,7 +165,7 @@ function M.reload(node, git_status) return ns end - sorters.sort(node.nodes) + M.sorters:sort(node.nodes) live_filter.apply_filter(node) log.profile_end(profile) return node.nodes @@ -229,6 +229,7 @@ function M.refresh_parent_nodes_for_path(path) end function M.setup(opts) + M.sorters = Sorters:new(opts) M.config = opts.renderer end diff --git a/lua/nvim-tree/explorer/sorters.lua b/lua/nvim-tree/explorer/sorters.lua index cb7400f512e..91a3eb40f59 100644 --- a/lua/nvim-tree/explorer/sorters.lua +++ b/lua/nvim-tree/explorer/sorters.lua @@ -1,5 +1,3 @@ -local M = {} - local C = {} --- Predefined comparator, defaulting to name @@ -27,17 +25,17 @@ end ---@param a Node ---@param b Node ---@return boolean|nil -local function folders_or_files_first(a, b) - if not (M.config.sort.folders_first or M.config.sort.files_first) then +local function folders_or_files_first(a, b, cfg) + if not (cfg.folders_first or cfg.files_first) then return end if not a.nodes and b.nodes then -- file <> folder - return M.config.sort.files_first + return cfg.files_first elseif a.nodes and not b.nodes then -- folder <> file - return not M.config.sort.files_first + return not cfg.files_first end end @@ -95,67 +93,17 @@ local function split_merge(t, first, last, comparator) merge(t, first, mid, last, comparator) end ----Perform a merge sort using sorter option. ----@param t table nodes -function M.sort(t) - if C.user then - local t_user = {} - local origin_index = {} - - for _, n in ipairs(t) do - table.insert(t_user, { - absolute_path = n.absolute_path, - executable = n.executable, - extension = n.extension, - filetype = vim.filetype.match { filename = n.name }, - link_to = n.link_to, - name = n.name, - type = n.type, - }) - table.insert(origin_index, n) - end - - local predefined = C.user(t_user) - if predefined then - split_merge(t, 1, #t, get_comparator(predefined)) - return - end - - -- do merge sort for prevent memory exceed - local user_index = {} - for i, v in ipairs(t_user) do - if type(v.absolute_path) == "string" and user_index[v.absolute_path] == nil then - user_index[v.absolute_path] = i - end - end - - -- if missing value found, then using origin_index - local mini_comparator = function(a, b) - local a_index = user_index[a.absolute_path] or origin_index[a.absolute_path] - local b_index = user_index[b.absolute_path] or origin_index[b.absolute_path] - - if type(a_index) == "number" and type(b_index) == "number" then - return a_index <= b_index - end - return (a_index or 0) <= (b_index or 0) - end - - split_merge(t, 1, #t, mini_comparator) -- sort by user order - else - split_merge(t, 1, #t, get_comparator(M.config.sort.sorter)) - end -end ---@param a Node ---@param b Node ---@param ignorecase boolean|nil ---@return boolean -local function node_comparator_name_ignorecase_or_not(a, b, ignorecase) +local function node_comparator_name_ignorecase_or_not(a, b, ignorecase, cfg) if not (a and b) then return true end - local early_return = folders_or_files_first(a, b) + local early_return = folders_or_files_first(a, b, cfg) if early_return ~= nil then return early_return end @@ -167,15 +115,16 @@ local function node_comparator_name_ignorecase_or_not(a, b, ignorecase) end end -function C.case_sensitive(a, b) - return node_comparator_name_ignorecase_or_not(a, b, false) + +function C.case_sensitive(a, b, cfg) + return node_comparator_name_ignorecase_or_not(a, b, false, cfg) end -function C.name(a, b) - return node_comparator_name_ignorecase_or_not(a, b, true) +function C.name(a, b, cfg) + return node_comparator_name_ignorecase_or_not(a, b, true, cfg) end -function C.modification_time(a, b) +function C.modification_time(a, b, cfg) if not (a and b) then return true end @@ -199,13 +148,13 @@ function C.modification_time(a, b) return last_modified_b <= last_modified_a end -function C.suffix(a, b) +function C.suffix(a, b, cfg) if not (a and b) then return true end -- directories go first - local early_return = folders_or_files_first(a, b) + local early_return = folders_or_files_first(a, b, cfg) if early_return ~= nil then return early_return elseif a.nodes and b.nodes then @@ -248,7 +197,7 @@ function C.suffix(a, b) return a_suffix:lower() < b_suffix:lower() end -function C.extension(a, b) +function C.extension(a, b, cfg) if not (a and b) then return true end @@ -273,12 +222,12 @@ function C.extension(a, b) return a_ext < b_ext end -function C.filetype(a, b) +function C.filetype(a, b, cfg) local a_ft = vim.filetype.match { filename = a.name } local b_ft = vim.filetype.match { filename = b.name } -- directories first - local early_return = folders_or_files_first(a, b) + local early_return = folders_or_files_first(a, b, cfg) if early_return ~= nil then return early_return end @@ -298,13 +247,77 @@ function C.filetype(a, b) return a_ft < b_ft end -function M.setup(opts) - M.config = {} - M.config.sort = opts.sort - if type(M.config.sort.sorter) == "function" then - C.user = M.config.sort.sorter +---@class Sorter +local Sorter = {} + +function Sorter:new (opts) + local o = {} -- create object if user does not provide one + setmetatable(o, self) + self.__index = self + o.config = opts.sort + + if type(o.config.sorter) == "function" then + o.user = o.config.sorter + end + return o +end + +function Sorter:get_comparator(sorter) + return function(a, b) + return (C[sorter] or C.name)(a, b, self.config) + end +end + +---Perform a merge sort using sorter option. +---@param t table nodes +function Sorter:sort(t) + if self.user then + local t_user = {} + local origin_index = {} + + for _, n in ipairs(t) do + table.insert(t_user, { + absolute_path = n.absolute_path, + executable = n.executable, + extension = n.extension, + filetype = vim.filetype.match { filename = n.name }, + link_to = n.link_to, + name = n.name, + type = n.type, + }) + table.insert(origin_index, n) + end + + local predefined = self.user(t_user) + if predefined then + split_merge(t, 1, #t, self:get_comparator(predefined)) + return + end + + -- do merge sort for prevent memory exceed + local user_index = {} + for i, v in ipairs(t_user) do + if type(v.absolute_path) == "string" and user_index[v.absolute_path] == nil then + user_index[v.absolute_path] = i + end + end + + -- if missing value found, then using origin_index + local mini_comparator = function(a, b) + local a_index = user_index[a.absolute_path] or origin_index[a.absolute_path] + local b_index = user_index[b.absolute_path] or origin_index[b.absolute_path] + + if type(a_index) == "number" and type(b_index) == "number" then + return a_index <= b_index + end + return (a_index or 0) <= (b_index or 0) + end + + split_merge(t, 1, #t, mini_comparator) -- sort by user order + else + split_merge(t, 1, #t, self:get_comparator(self.config.sorter)) end end -return M +return Sorter From deb4f1b455fd751fe445e9d01de459b1b05e3809 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Sat, 13 Jul 2024 17:01:27 +0200 Subject: [PATCH 2/8] fix: linter errors --- lua/nvim-tree/explorer/sorters.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lua/nvim-tree/explorer/sorters.lua b/lua/nvim-tree/explorer/sorters.lua index 91a3eb40f59..2a915abcb65 100644 --- a/lua/nvim-tree/explorer/sorters.lua +++ b/lua/nvim-tree/explorer/sorters.lua @@ -1,11 +1,5 @@ local C = {} ---- Predefined comparator, defaulting to name ----@param sorter string as per options ----@return function -local function get_comparator(sorter) - return C[sorter] or C.name -end ---Create a shallow copy of a portion of a list. ---@param t table @@ -124,7 +118,7 @@ function C.name(a, b, cfg) return node_comparator_name_ignorecase_or_not(a, b, true, cfg) end -function C.modification_time(a, b, cfg) +function C.modification_time(a, b) if not (a and b) then return true end @@ -197,7 +191,7 @@ function C.suffix(a, b, cfg) return a_suffix:lower() < b_suffix:lower() end -function C.extension(a, b, cfg) +function C.extension(a, b) if not (a and b) then return true end @@ -248,7 +242,7 @@ function C.filetype(a, b, cfg) end ----@class Sorter +---@class Sorter local Sorter = {} function Sorter:new (opts) @@ -263,6 +257,9 @@ function Sorter:new (opts) return o end +--- Predefined comparator, defaulting to name +---@param sorter string as per options +---@return function function Sorter:get_comparator(sorter) return function(a, b) return (C[sorter] or C.name)(a, b, self.config) From 7c778ce55a322c8023e7ac7484228d376c4d5554 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Sat, 13 Jul 2024 17:06:12 +0200 Subject: [PATCH 3/8] fix: style --- lua/nvim-tree/explorer/sorters.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lua/nvim-tree/explorer/sorters.lua b/lua/nvim-tree/explorer/sorters.lua index 2a915abcb65..993418ad519 100644 --- a/lua/nvim-tree/explorer/sorters.lua +++ b/lua/nvim-tree/explorer/sorters.lua @@ -1,6 +1,5 @@ local C = {} - ---Create a shallow copy of a portion of a list. ---@param t table ---@param first integer First index, inclusive @@ -87,7 +86,6 @@ local function split_merge(t, first, last, comparator) merge(t, first, mid, last, comparator) end - ---@param a Node ---@param b Node ---@param ignorecase boolean|nil @@ -109,7 +107,6 @@ local function node_comparator_name_ignorecase_or_not(a, b, ignorecase, cfg) end end - function C.case_sensitive(a, b, cfg) return node_comparator_name_ignorecase_or_not(a, b, false, cfg) end @@ -241,12 +238,11 @@ function C.filetype(a, b, cfg) return a_ft < b_ft end - ---@class Sorter local Sorter = {} -function Sorter:new (opts) - local o = {} -- create object if user does not provide one +function Sorter:new(opts) + local o = {} -- create object if user does not provide one setmetatable(o, self) self.__index = self o.config = opts.sort From 8dbb773e127b76aa312c5228e574e27265734806 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Sun, 14 Jul 2024 13:19:42 +0200 Subject: [PATCH 4/8] fix: according to code review --- lua/nvim-tree/explorer/explore.lua | 3 +- lua/nvim-tree/explorer/init.lua | 2 + lua/nvim-tree/explorer/reload.lua | 6 +- lua/nvim-tree/explorer/sorters.lua | 150 ++++++++++++++--------------- 4 files changed, 82 insertions(+), 79 deletions(-) diff --git a/lua/nvim-tree/explorer/explore.lua b/lua/nvim-tree/explorer/explore.lua index 14e1ecc6944..4b4beafe854 100644 --- a/lua/nvim-tree/explorer/explore.lua +++ b/lua/nvim-tree/explorer/explore.lua @@ -82,7 +82,7 @@ function M.explore(node, status, parent) return ns end - M.sorters:sort(node.nodes) + parent.sorters:sort(node.nodes) live_filter.apply_filter(node) log.profile_end(profile) @@ -90,7 +90,6 @@ function M.explore(node, status, parent) end function M.setup(opts) - M.sorters = Sorters:new(opts) M.config = opts.renderer end diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua index 5b682b72c55..9696148e819 100644 --- a/lua/nvim-tree/explorer/init.lua +++ b/lua/nvim-tree/explorer/init.lua @@ -4,6 +4,7 @@ local watch = require "nvim-tree.explorer.watch" local explorer_node = require "nvim-tree.explorer.node" local Filters = require "nvim-tree.explorer.filters" local Marks = require "nvim-tree.marks" +local Sorters = require "nvim-tree.explorer.sorters" local M = {} @@ -40,6 +41,7 @@ function Explorer.new(path) nodes = {}, open = true, marks = Marks:new(), + sorters = Sorters:new(M.config) }, Explorer) explorer.watcher = watch.create_watcher(explorer) explorer.filters = Filters:new(M.config, explorer) diff --git a/lua/nvim-tree/explorer/reload.lua b/lua/nvim-tree/explorer/reload.lua index 56de75e535a..48d91b9109f 100644 --- a/lua/nvim-tree/explorer/reload.lua +++ b/lua/nvim-tree/explorer/reload.lua @@ -165,7 +165,10 @@ function M.reload(node, git_status) return ns end - M.sorters:sort(node.nodes) + local explorer = require("nvim-tree.core").get_explorer() + if explorer then + explorer.sorters:sort(node.nodes) + end live_filter.apply_filter(node) log.profile_end(profile) return node.nodes @@ -229,7 +232,6 @@ function M.refresh_parent_nodes_for_path(path) end function M.setup(opts) - M.sorters = Sorters:new(opts) M.config = opts.renderer end diff --git a/lua/nvim-tree/explorer/sorters.lua b/lua/nvim-tree/explorer/sorters.lua index 993418ad519..182f10e7620 100644 --- a/lua/nvim-tree/explorer/sorters.lua +++ b/lua/nvim-tree/explorer/sorters.lua @@ -1,5 +1,29 @@ local C = {} +---@class Sorter +local Sorter = {} + +function Sorter:new(opts) + local o = {} -- create object if user does not provide one + setmetatable(o, self) + self.__index = self + o.config = vim.deepcopy(opts.sort) + + if type(o.config.sorter) == "function" then + o.user = o.config.sorter + end + return o +end + +--- Predefined comparator, defaulting to name +---@param sorter string as per options +---@return function +function Sorter:get_comparator(sorter) + return function(a, b) + return (C[sorter] or C.name)(a, b, self.config) + end +end + ---Create a shallow copy of a portion of a list. ---@param t table ---@param first integer First index, inclusive @@ -86,6 +110,57 @@ local function split_merge(t, first, last, comparator) merge(t, first, mid, last, comparator) end +---Perform a merge sort using sorter option. +---@param t table nodes +function Sorter:sort(t) + if self.user then + local t_user = {} + local origin_index = {} + + for _, n in ipairs(t) do + table.insert(t_user, { + absolute_path = n.absolute_path, + executable = n.executable, + extension = n.extension, + filetype = vim.filetype.match { filename = n.name }, + link_to = n.link_to, + name = n.name, + type = n.type, + }) + table.insert(origin_index, n) + end + + local predefined = self.user(t_user) + if predefined then + split_merge(t, 1, #t, self:get_comparator(predefined)) + return + end + + -- do merge sort for prevent memory exceed + local user_index = {} + for i, v in ipairs(t_user) do + if type(v.absolute_path) == "string" and user_index[v.absolute_path] == nil then + user_index[v.absolute_path] = i + end + end + + -- if missing value found, then using origin_index + local mini_comparator = function(a, b) + local a_index = user_index[a.absolute_path] or origin_index[a.absolute_path] + local b_index = user_index[b.absolute_path] or origin_index[b.absolute_path] + + if type(a_index) == "number" and type(b_index) == "number" then + return a_index <= b_index + end + return (a_index or 0) <= (b_index or 0) + end + + split_merge(t, 1, #t, mini_comparator) -- sort by user order + else + split_merge(t, 1, #t, self:get_comparator(self.config.sorter)) + end +end + ---@param a Node ---@param b Node ---@param ignorecase boolean|nil @@ -238,79 +313,4 @@ function C.filetype(a, b, cfg) return a_ft < b_ft end ----@class Sorter -local Sorter = {} - -function Sorter:new(opts) - local o = {} -- create object if user does not provide one - setmetatable(o, self) - self.__index = self - o.config = opts.sort - - if type(o.config.sorter) == "function" then - o.user = o.config.sorter - end - return o -end - ---- Predefined comparator, defaulting to name ----@param sorter string as per options ----@return function -function Sorter:get_comparator(sorter) - return function(a, b) - return (C[sorter] or C.name)(a, b, self.config) - end -end - ----Perform a merge sort using sorter option. ----@param t table nodes -function Sorter:sort(t) - if self.user then - local t_user = {} - local origin_index = {} - - for _, n in ipairs(t) do - table.insert(t_user, { - absolute_path = n.absolute_path, - executable = n.executable, - extension = n.extension, - filetype = vim.filetype.match { filename = n.name }, - link_to = n.link_to, - name = n.name, - type = n.type, - }) - table.insert(origin_index, n) - end - - local predefined = self.user(t_user) - if predefined then - split_merge(t, 1, #t, self:get_comparator(predefined)) - return - end - - -- do merge sort for prevent memory exceed - local user_index = {} - for i, v in ipairs(t_user) do - if type(v.absolute_path) == "string" and user_index[v.absolute_path] == nil then - user_index[v.absolute_path] = i - end - end - - -- if missing value found, then using origin_index - local mini_comparator = function(a, b) - local a_index = user_index[a.absolute_path] or origin_index[a.absolute_path] - local b_index = user_index[b.absolute_path] or origin_index[b.absolute_path] - - if type(a_index) == "number" and type(b_index) == "number" then - return a_index <= b_index - end - return (a_index or 0) <= (b_index or 0) - end - - split_merge(t, 1, #t, mini_comparator) -- sort by user order - else - split_merge(t, 1, #t, self:get_comparator(self.config.sorter)) - end -end - return Sorter From 5d5c2afb72160be282cd51fc116c4d08e2b2e2b9 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Sun, 14 Jul 2024 15:03:04 +0200 Subject: [PATCH 5/8] chore: removed comment --- lua/nvim-tree/explorer/sorters.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-tree/explorer/sorters.lua b/lua/nvim-tree/explorer/sorters.lua index 182f10e7620..cab9b292033 100644 --- a/lua/nvim-tree/explorer/sorters.lua +++ b/lua/nvim-tree/explorer/sorters.lua @@ -4,7 +4,7 @@ local C = {} local Sorter = {} function Sorter:new(opts) - local o = {} -- create object if user does not provide one + local o = {} setmetatable(o, self) self.__index = self o.config = vim.deepcopy(opts.sort) From 0ad725806938f3c3dcbd69a6bd60aef340de9c84 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Tue, 23 Jul 2024 14:27:37 +0200 Subject: [PATCH 6/8] fix: missing cfg params in sorters --- lua/nvim-tree/explorer/sorters.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lua/nvim-tree/explorer/sorters.lua b/lua/nvim-tree/explorer/sorters.lua index cab9b292033..3fa40c9d3b7 100644 --- a/lua/nvim-tree/explorer/sorters.lua +++ b/lua/nvim-tree/explorer/sorters.lua @@ -190,12 +190,12 @@ function C.name(a, b, cfg) return node_comparator_name_ignorecase_or_not(a, b, true, cfg) end -function C.modification_time(a, b) +function C.modification_time(a, b, cfg) if not (a and b) then return true end - local early_return = folders_or_files_first(a, b) + local early_return = folders_or_files_first(a, b, cfg) if early_return ~= nil then return early_return end @@ -224,7 +224,7 @@ function C.suffix(a, b, cfg) if early_return ~= nil then return early_return elseif a.nodes and b.nodes then - return C.name(a, b) + return C.name(a, b, cfg) end -- dotfiles go second @@ -233,7 +233,7 @@ function C.suffix(a, b, cfg) elseif a.name:sub(1, 1) ~= "." and b.name:sub(1, 1) == "." then return false elseif a.name:sub(1, 1) == "." and b.name:sub(1, 1) == "." then - return C.name(a, b) + return C.name(a, b, cfg) end -- unsuffixed go third @@ -245,7 +245,7 @@ function C.suffix(a, b, cfg) elseif a_suffix_ndx and not b_suffix_ndx then return false elseif not (a_suffix_ndx and b_suffix_ndx) then - return C.name(a, b) + return C.name(a, b, cfg) end -- finally, compare by suffixes @@ -257,18 +257,18 @@ function C.suffix(a, b, cfg) elseif not a_suffix and b_suffix then return false elseif a_suffix:lower() == b_suffix:lower() then - return C.name(a, b) + return C.name(a, b, cfg) end return a_suffix:lower() < b_suffix:lower() end -function C.extension(a, b) +function C.extension(a, b, cfg) if not (a and b) then return true end - local early_return = folders_or_files_first(a, b) + local early_return = folders_or_files_first(a, b, cfg) if early_return ~= nil then return early_return end @@ -282,7 +282,7 @@ function C.extension(a, b) local a_ext = (a.extension or ""):lower() local b_ext = (b.extension or ""):lower() if a_ext == b_ext then - return C.name(a, b) + return C.name(a, b, cfg) end return a_ext < b_ext @@ -307,7 +307,7 @@ function C.filetype(a, b, cfg) -- same filetype or both nil, sort by name if a_ft == b_ft then - return C.name(a, b) + return C.name(a, b, cfg) end return a_ft < b_ft From b7b0bc0a9a4d162a761ced8dc73c3955ba2db1d3 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 27 Jul 2024 13:52:02 +1000 Subject: [PATCH 7/8] tidy following rebase --- lua/nvim-tree/explorer/explore.lua | 1 - lua/nvim-tree/explorer/init.lua | 1 - lua/nvim-tree/explorer/reload.lua | 6 +----- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lua/nvim-tree/explorer/explore.lua b/lua/nvim-tree/explorer/explore.lua index 4b4beafe854..3d48f95a583 100644 --- a/lua/nvim-tree/explorer/explore.lua +++ b/lua/nvim-tree/explorer/explore.lua @@ -2,7 +2,6 @@ local utils = require "nvim-tree.utils" local builders = require "nvim-tree.explorer.node-builders" local explorer_node = require "nvim-tree.explorer.node" local git = require "nvim-tree.git" -local Sorters = require "nvim-tree.explorer.sorters" local live_filter = require "nvim-tree.live-filter" local log = require "nvim-tree.log" diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua index 9696148e819..107c103ef62 100644 --- a/lua/nvim-tree/explorer/init.lua +++ b/lua/nvim-tree/explorer/init.lua @@ -78,7 +78,6 @@ function M.setup(opts) M.config = opts require("nvim-tree.explorer.node").setup(opts) require("nvim-tree.explorer.explore").setup(opts) - require("nvim-tree.explorer.sorters").setup(opts) require("nvim-tree.explorer.reload").setup(opts) require("nvim-tree.explorer.watch").setup(opts) end diff --git a/lua/nvim-tree/explorer/reload.lua b/lua/nvim-tree/explorer/reload.lua index 48d91b9109f..101a22cf000 100644 --- a/lua/nvim-tree/explorer/reload.lua +++ b/lua/nvim-tree/explorer/reload.lua @@ -1,7 +1,6 @@ local utils = require "nvim-tree.utils" local builders = require "nvim-tree.explorer.node-builders" local explorer_node = require "nvim-tree.explorer.node" -local Sorters = require "nvim-tree.explorer.sorters" local live_filter = require "nvim-tree.live-filter" local git = require "nvim-tree.git" local log = require "nvim-tree.log" @@ -165,10 +164,7 @@ function M.reload(node, git_status) return ns end - local explorer = require("nvim-tree.core").get_explorer() - if explorer then - explorer.sorters:sort(node.nodes) - end + explorer.sorters:sort(node.nodes) live_filter.apply_filter(node) log.profile_end(profile) return node.nodes From 4fcf63ece132757ab546bd7aed50af457a264a2e Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 27 Jul 2024 13:53:47 +1000 Subject: [PATCH 8/8] tidy following rebase --- lua/nvim-tree/explorer/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua index 107c103ef62..5dc085e7ee3 100644 --- a/lua/nvim-tree/explorer/init.lua +++ b/lua/nvim-tree/explorer/init.lua @@ -41,7 +41,7 @@ function Explorer.new(path) nodes = {}, open = true, marks = Marks:new(), - sorters = Sorters:new(M.config) + sorters = Sorters:new(M.config), }, Explorer) explorer.watcher = watch.create_watcher(explorer) explorer.filters = Filters:new(M.config, explorer)