BREAKING: rename populate -> explorer
- rename populate.lua to explorer.lua - rename refresh_entries to refresh in explorer.lua - rename populate to explore in explorer.lua
This commit is contained in:
@@ -355,7 +355,7 @@ function M.setup(conf)
|
|||||||
require'nvim-tree.actions'.setup(opts)
|
require'nvim-tree.actions'.setup(opts)
|
||||||
require'nvim-tree.view'.setup(opts.view or {})
|
require'nvim-tree.view'.setup(opts.view or {})
|
||||||
require'nvim-tree.diagnostics'.setup(opts)
|
require'nvim-tree.diagnostics'.setup(opts)
|
||||||
require'nvim-tree.populate'.setup(opts)
|
require'nvim-tree.explorer'.setup(opts)
|
||||||
require'nvim-tree.git'.setup(opts)
|
require'nvim-tree.git'.setup(opts)
|
||||||
|
|
||||||
setup_autocommands(opts)
|
setup_autocommands(opts)
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ local function should_ignore_git(path, status)
|
|||||||
and (M.config.filter_git_ignored and status and status[path] == '!!')
|
and (M.config.filter_git_ignored and status and status[path] == '!!')
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.refresh_entries(entries, cwd, parent_node, status)
|
function M.refresh(nodes, cwd, parent_node, status)
|
||||||
local handle = luv.fs_scandir(cwd)
|
local handle = luv.fs_scandir(cwd)
|
||||||
if type(handle) == 'string' then
|
if type(handle) == 'string' then
|
||||||
api.nvim_err_writeln(handle)
|
api.nvim_err_writeln(handle)
|
||||||
@@ -169,7 +169,7 @@ function M.refresh_entries(entries, cwd, parent_node, status)
|
|||||||
local named_entries = {}
|
local named_entries = {}
|
||||||
local cached_entries = {}
|
local cached_entries = {}
|
||||||
local entries_idx = {}
|
local entries_idx = {}
|
||||||
for i, node in ipairs(entries) do
|
for i, node in ipairs(nodes) do
|
||||||
node.git_status = (parent_node and parent_node.git_status == '!!' and '!!')
|
node.git_status = (parent_node and parent_node.git_status == '!!' and '!!')
|
||||||
or (status.files and status.files[node.absolute_path])
|
or (status.files and status.files[node.absolute_path])
|
||||||
or (status.dirs and status.dirs[node.absolute_path])
|
or (status.dirs and status.dirs[node.absolute_path])
|
||||||
@@ -219,7 +219,7 @@ function M.refresh_entries(entries, cwd, parent_node, status)
|
|||||||
parent_node.group_next = nil
|
parent_node.group_next = nil
|
||||||
named_entries[next_node.name] = next_node
|
named_entries[next_node.name] = next_node
|
||||||
else
|
else
|
||||||
M.refresh_entries(entries, next_node.absolute_path, next_node, status)
|
M.refresh(nodes, next_node.absolute_path, next_node, status)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -237,7 +237,7 @@ function M.refresh_entries(entries, cwd, parent_node, status)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not new_entries[name] then
|
if not new_entries[name] then
|
||||||
table.remove(entries, idx)
|
table.remove(nodes, idx)
|
||||||
else
|
else
|
||||||
idx = idx + 1
|
idx = idx + 1
|
||||||
end
|
end
|
||||||
@@ -263,7 +263,7 @@ function M.refresh_entries(entries, cwd, parent_node, status)
|
|||||||
if prev then
|
if prev then
|
||||||
idx = entries_idx[prev] + 1
|
idx = entries_idx[prev] + 1
|
||||||
end
|
end
|
||||||
table.insert(entries, idx, n)
|
table.insert(nodes, idx, n)
|
||||||
entries_idx[name] = idx
|
entries_idx[name] = idx
|
||||||
cached_entries[idx] = name
|
cached_entries[idx] = name
|
||||||
else
|
else
|
||||||
@@ -277,15 +277,15 @@ function M.refresh_entries(entries, cwd, parent_node, status)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if next_node then
|
if next_node then
|
||||||
table.insert(entries, 1, next_node)
|
table.insert(nodes, 1, next_node)
|
||||||
end
|
end
|
||||||
|
|
||||||
if new_nodes_added then
|
if new_nodes_added then
|
||||||
utils.merge_sort(entries, node_comparator)
|
utils.merge_sort(nodes, node_comparator)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.populate(entries, cwd, parent_node, status)
|
function M.explore(entries, cwd, parent_node, status)
|
||||||
local handle = luv.fs_scandir(cwd)
|
local handle = luv.fs_scandir(cwd)
|
||||||
if type(handle) == 'string' then
|
if type(handle) == 'string' then
|
||||||
api.nvim_err_writeln(handle)
|
api.nvim_err_writeln(handle)
|
||||||
@@ -327,7 +327,7 @@ function M.populate(entries, cwd, parent_node, status)
|
|||||||
if luv.fs_access(child_node.absolute_path, 'R') then
|
if luv.fs_access(child_node.absolute_path, 'R') then
|
||||||
parent_node.group_next = child_node
|
parent_node.group_next = child_node
|
||||||
child_node.git_status = parent_node.git_status
|
child_node.git_status = parent_node.git_status
|
||||||
M.populate(entries, child_node.absolute_path, child_node, status)
|
M.explore(entries, child_node.absolute_path, child_node, status)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3,13 +3,11 @@ local luv = vim.loop
|
|||||||
|
|
||||||
local renderer = require'nvim-tree.renderer'
|
local renderer = require'nvim-tree.renderer'
|
||||||
local diagnostics = require'nvim-tree.diagnostics'
|
local diagnostics = require'nvim-tree.diagnostics'
|
||||||
local pops = require'nvim-tree.populate'
|
local explorer = require'nvim-tree.explorer'
|
||||||
local utils = require'nvim-tree.utils'
|
local utils = require'nvim-tree.utils'
|
||||||
local view = require'nvim-tree.view'
|
local view = require'nvim-tree.view'
|
||||||
local events = require'nvim-tree.events'
|
local events = require'nvim-tree.events'
|
||||||
local git = require'nvim-tree.git'
|
local git = require'nvim-tree.git'
|
||||||
local populate = pops.populate
|
|
||||||
local refresh_entries = pops.refresh_entries
|
|
||||||
|
|
||||||
local first_init_done = false
|
local first_init_done = false
|
||||||
|
|
||||||
@@ -23,7 +21,7 @@ M.Tree = {
|
|||||||
|
|
||||||
local function load_children(cwd, children, parent)
|
local function load_children(cwd, children, parent)
|
||||||
git.load_project_status(cwd, function(git_statuses)
|
git.load_project_status(cwd, function(git_statuses)
|
||||||
populate(children, cwd, parent, git_statuses)
|
explorer.explore(children, cwd, parent, git_statuses)
|
||||||
M.redraw()
|
M.redraw()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -141,7 +139,7 @@ end
|
|||||||
|
|
||||||
local function refresh_nodes(node, projects)
|
local function refresh_nodes(node, projects)
|
||||||
local project_root = git.get_project_root(node.absolute_path or node.cwd)
|
local project_root = git.get_project_root(node.absolute_path or node.cwd)
|
||||||
refresh_entries(node.entries, node.absolute_path or node.cwd, node, projects[project_root] or {})
|
explorer.refresh(node.entries, node.absolute_path or node.cwd, node, projects[project_root] or {})
|
||||||
for _, entry in ipairs(node.entries) do
|
for _, entry in ipairs(node.entries) do
|
||||||
if entry.entries and entry.open then
|
if entry.entries and entry.open then
|
||||||
refresh_nodes(entry, projects)
|
refresh_nodes(entry, projects)
|
||||||
@@ -219,7 +217,7 @@ function M.set_index_and_redraw(fname)
|
|||||||
if path_matches then
|
if path_matches then
|
||||||
if #node.entries == 0 then
|
if #node.entries == 0 then
|
||||||
node.open = true
|
node.open = true
|
||||||
populate(node.entries, node.absolute_path, node, {})
|
explorer.explore(node.entries, node.absolute_path, node, {})
|
||||||
git.load_project_status(node.absolute_path, function(status)
|
git.load_project_status(node.absolute_path, function(status)
|
||||||
if status.dirs or status.files then
|
if status.dirs or status.files then
|
||||||
reload_node_status(node, git.projects)
|
reload_node_status(node, git.projects)
|
||||||
@@ -384,12 +382,12 @@ function M.parent_node(node, should_close)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.toggle_ignored()
|
function M.toggle_ignored()
|
||||||
pops.config.filter_ignored = not pops.config.filter_ignored
|
explorer.config.filter_ignored = not explorer.config.filter_ignored
|
||||||
return M.refresh_tree()
|
return M.refresh_tree()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.toggle_dotfiles()
|
function M.toggle_dotfiles()
|
||||||
pops.config.filter_dotfiles = not pops.config.filter_dotfiles
|
explorer.config.filter_dotfiles = not explorer.config.filter_dotfiles
|
||||||
return M.refresh_tree()
|
return M.refresh_tree()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user