refactor: all usages going through the explorer
This commit is contained in:
parent
c6ae2431bc
commit
9deac32a40
@ -837,7 +837,6 @@ function M.setup(conf)
|
||||
require("nvim-tree.view").setup(opts)
|
||||
require("nvim-tree.lib").setup(opts)
|
||||
require("nvim-tree.renderer").setup(opts)
|
||||
require("nvim-tree.live-filter").setup(opts)
|
||||
require("nvim-tree.marks").setup(opts)
|
||||
require("nvim-tree.buffers").setup(opts)
|
||||
require("nvim-tree.help").setup(opts)
|
||||
|
||||
@ -6,7 +6,6 @@ local actions = require "nvim-tree.actions"
|
||||
local appearance_diagnostics = require "nvim-tree.appearance.diagnostics"
|
||||
local events = require "nvim-tree.events"
|
||||
local help = require "nvim-tree.help"
|
||||
local live_filter = require "nvim-tree.live-filter"
|
||||
local marks_navigation = require "nvim-tree.marks.navigation"
|
||||
local marks_bulk_delete = require "nvim-tree.marks.bulk-delete"
|
||||
local marks_bulk_trash = require "nvim-tree.marks.bulk-trash"
|
||||
@ -265,8 +264,16 @@ Api.git.reload = wrap(actions.reloaders.reload_git)
|
||||
Api.events.subscribe = events.subscribe
|
||||
Api.events.Event = events.Event
|
||||
|
||||
Api.live_filter.start = wrap(live_filter.start_filtering)
|
||||
Api.live_filter.clear = wrap(live_filter.clear_filter)
|
||||
Api.live_filter.start = wrap_explorer(function(explorer)
|
||||
return wrap(function(...)
|
||||
return explorer.live_filter:start_filtering(...)
|
||||
end)
|
||||
end)
|
||||
Api.live_filter.clear = wrap_explorer(function(explorer)
|
||||
return wrap(function(...)
|
||||
return explorer.live_filter:clear_filter(...)
|
||||
end)
|
||||
end)
|
||||
|
||||
Api.marks.get = wrap_node(wrap_explorer_member("marks", "get_mark"))
|
||||
Api.marks.list = wrap_explorer_member("marks", "get_marks")
|
||||
|
||||
@ -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 live_filter = require "nvim-tree.live-filter"
|
||||
local log = require "nvim-tree.log"
|
||||
|
||||
local Watcher = require "nvim-tree.watcher"
|
||||
@ -82,7 +81,7 @@ function M.explore(node, status, parent)
|
||||
end
|
||||
|
||||
parent.sorters:sort(node.nodes)
|
||||
live_filter.apply_filter(node)
|
||||
parent.live_filter:apply_filter(node)
|
||||
|
||||
log.profile_end(profile)
|
||||
return node.nodes
|
||||
|
||||
@ -4,7 +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 LiveFilter = require "nvim-tree.live-filter"
|
||||
local LiveFilter = require "nvim-tree.explorer.live-filter"
|
||||
local Sorters = require "nvim-tree.explorer.sorters"
|
||||
|
||||
local M = {}
|
||||
|
||||
@ -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 live_filter = require "nvim-tree.live-filter"
|
||||
local git = require "nvim-tree.git"
|
||||
local log = require "nvim-tree.log"
|
||||
|
||||
@ -165,7 +164,7 @@ function M.reload(node, git_status)
|
||||
end
|
||||
|
||||
explorer.sorters:sort(node.nodes)
|
||||
live_filter.apply_filter(node)
|
||||
explorer.live_filter:apply_filter(node)
|
||||
log.profile_end(profile)
|
||||
return node.nodes
|
||||
end
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
local core = require "nvim-tree.core"
|
||||
local live_filter = require "nvim-tree.live-filter"
|
||||
local notify = require "nvim-tree.notify"
|
||||
local utils = require "nvim-tree.utils"
|
||||
local view = require "nvim-tree.view"
|
||||
@ -352,7 +351,8 @@ end
|
||||
|
||||
---@private
|
||||
function Builder:get_nodes_number(nodes)
|
||||
if not live_filter.filter then
|
||||
local explorer = core.get_explorer()
|
||||
if not explorer or not explorer.live_filter.filter then
|
||||
return #nodes
|
||||
end
|
||||
|
||||
@ -398,6 +398,7 @@ end
|
||||
|
||||
---@private
|
||||
function Builder:build_header()
|
||||
local explorer = core.get_explorer()
|
||||
if view.is_root_folder_visible(core.get_cwd()) then
|
||||
local root_name = self:format_root_name(M.opts.renderer.root_folder_label)
|
||||
table.insert(self.lines, root_name)
|
||||
@ -405,8 +406,8 @@ function Builder:build_header()
|
||||
self.index = 1
|
||||
end
|
||||
|
||||
if live_filter.filter then
|
||||
local filter_line = string.format("%s/%s/", M.opts.live_filter.prefix, live_filter.filter)
|
||||
if explorer and explorer.live_filter.filter then
|
||||
local filter_line = string.format("%s/%s/", M.opts.live_filter.prefix, explorer.live_filter.filter)
|
||||
table.insert(self.lines, filter_line)
|
||||
local prefix_length = string.len(M.opts.live_filter.prefix)
|
||||
self:insert_highlight({ "NvimTreeLiveFilterPrefix" }, 0, prefix_length)
|
||||
|
||||
@ -112,7 +112,10 @@ function M.find_node(nodes, fn)
|
||||
end)
|
||||
:iterate()
|
||||
i = require("nvim-tree.view").is_root_folder_visible() and i or i - 1
|
||||
i = require("nvim-tree.live-filter").filter and i + 1 or i
|
||||
local explorer = require("nvim-tree.core").get_explorer()
|
||||
if explorer and explorer.live_filter.filter then
|
||||
i = i + 1
|
||||
end
|
||||
return node, i
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user