show some icon on opendir even if show_on_open_dir=false
and show all children's status on parent
This commit is contained in:
@@ -4,6 +4,7 @@ local git_utils = require "nvim-tree.git.utils"
|
||||
local Runner = require "nvim-tree.git.runner"
|
||||
local Watcher = require("nvim-tree.watcher").Watcher
|
||||
local Iterator = require "nvim-tree.iterators.node-iterator"
|
||||
local explorer_common = require "nvim-tree.explorer.common"
|
||||
|
||||
local M = {
|
||||
config = {},
|
||||
@@ -103,19 +104,13 @@ local function reload_tree_at(project_root)
|
||||
end
|
||||
|
||||
M.reload_project(project_root)
|
||||
local project = M.get_project(project_root)
|
||||
|
||||
local project_files = project.files and project.files or {}
|
||||
local project_dirs = project.dirs and project.dirs or {}
|
||||
local git_status = M.get_project(project_root)
|
||||
|
||||
Iterator.builder(root_node.nodes)
|
||||
:hidden()
|
||||
:applier(function(node)
|
||||
local parent_ignored = node.parent.git_status == "!!"
|
||||
node.git_status = project_dirs[node.absolute_path] or project_files[node.absolute_path]
|
||||
if not node.git_status and parent_ignored then
|
||||
node.git_status = "!!"
|
||||
end
|
||||
local parent_ignored = explorer_common.is_git_ignored(node.parent)
|
||||
explorer_common.update_git_status(node, parent_ignored, git_status)
|
||||
end)
|
||||
:recursor(function(node)
|
||||
return node.nodes and #node.nodes > 0 and node.nodes
|
||||
|
||||
@@ -55,24 +55,43 @@ function M.should_show_untracked(cwd)
|
||||
return untracked[cwd]
|
||||
end
|
||||
|
||||
local function nil_insert(t, k)
|
||||
t = t or {}
|
||||
t[k] = true
|
||||
return t
|
||||
end
|
||||
|
||||
function M.file_status_to_dir_status(status, cwd)
|
||||
local dirs = {}
|
||||
local direct = {}
|
||||
for p, s in pairs(status) do
|
||||
if s ~= "!!" then
|
||||
local modified = vim.fn.fnamemodify(p, ":h")
|
||||
dirs[modified] = s
|
||||
direct[modified] = nil_insert(direct[modified], s)
|
||||
end
|
||||
end
|
||||
|
||||
for dirname, s in pairs(dirs) do
|
||||
local modified = dirname
|
||||
while modified ~= cwd and modified ~= "/" do
|
||||
modified = vim.fn.fnamemodify(modified, ":h")
|
||||
dirs[modified] = s
|
||||
local indirect = {}
|
||||
for dirname, statuses in pairs(direct) do
|
||||
for s, _ in pairs(statuses) do
|
||||
local modified = dirname
|
||||
while modified ~= cwd and modified ~= "/" do
|
||||
modified = vim.fn.fnamemodify(modified, ":h")
|
||||
indirect[modified] = nil_insert(indirect[modified], s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return dirs
|
||||
local r = { indirect = indirect, direct = direct }
|
||||
for _, d in pairs(r) do
|
||||
for dirname, statuses in pairs(d) do
|
||||
local new_statuses = {}
|
||||
for s, _ in pairs(statuses) do
|
||||
table.insert(new_statuses, s)
|
||||
end
|
||||
d[dirname] = new_statuses
|
||||
end
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user