chore: resolve undefined-field warnings, fix link git statuses, rewrite devicons (#2968)
* add todo * refactor(#2886): multi instance: node class refactoring: extract links, *_git_status (#2944) * extract DirectoryLinkNode and FileLinkNode, move Node methods to children * temporarily move DirectoryNode methods into BaseNode for easier reviewing * move mostly unchanged DirectoryNode methods back to BaseNode * tidy * git.git_status_file takes an array * update git status of links * luacheck hack * safer git_status_dir * refactor(#2886): multi instance: node class refactoring: DirectoryNode:expand_or_collapse (#2957) move expand_or_collapse to DirectoryNode * refactor(#2886): multi instance: node group functions refactoring (#2959) * move last_group_node to DirectoryNode * move add BaseNode:as and more doc * revert parameter name changes * revert parameter name changes * add Class * move group methods into DN * tidy group methods * tidy group methods * tidy group methods * tidy group methods * parent is DirectoryNode * tidy expand all * BaseNode -> Node * move watcher to DirectoryNode * last_group_node is DirectoryNode only * simplify create-file * simplify parent * simplify collapse-all * simplify live-filter * style * move lib.get_cursor_position to Explorer * move lib.get_node_at_cursor to Explorer * move lib.get_nodes to Explorer * move place_cursor_on_node to Explorer * resolve resource leak in purge_all_state * move many autocommands into Explorer * post merge tidy * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * Revert "chore: resolve undefined-field" This reverts commit be546ff18d41f28466b065c857e1e041659bd2c8. * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * Revert "chore: resolve undefined-field" This reverts commite82db1c44d. * chore: resolve undefined-field * chore: class new is now generic * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * Revert "chore: resolve undefined-field" This reverts commit0e9b844d22. * move icon builders into node classes * move icon builders into node classes * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * chore: resolve undefined-field * move folder specifics from icons to Directory * move folder specifics from icons to Directory * move folder specifics from icons to Directory * move folder specifics from icons to Directory * move file specifics from icons to File * clean up sorters * chore: resolve undefined-field * tidy hl icon name * file devicon uses library to fall back * file devicon uses library to fall back * file devicon uses library to fall back
This commit is contained in:
committed by
GitHub
parent
c22124b374
commit
610a1c189b
@@ -58,10 +58,11 @@ function M.get_toplevel(cwd)
|
||||
return toplevel, git_dir
|
||||
end
|
||||
|
||||
---@type table<string, boolean>
|
||||
local untracked = {}
|
||||
|
||||
---@param cwd string
|
||||
---@return string|nil
|
||||
---@return boolean
|
||||
function M.should_show_untracked(cwd)
|
||||
if untracked[cwd] ~= nil then
|
||||
return untracked[cwd]
|
||||
@@ -81,8 +82,8 @@ function M.should_show_untracked(cwd)
|
||||
return untracked[cwd]
|
||||
end
|
||||
|
||||
---@param t table|nil
|
||||
---@param k string
|
||||
---@param t table<string|integer, boolean>?
|
||||
---@param k string|integer
|
||||
---@return table
|
||||
local function nil_insert(t, k)
|
||||
t = t or {}
|
||||
@@ -90,31 +91,33 @@ local function nil_insert(t, k)
|
||||
return t
|
||||
end
|
||||
|
||||
---@param status table
|
||||
---@param project_files GitProjectFiles
|
||||
---@param cwd string|nil
|
||||
---@return table
|
||||
function M.file_status_to_dir_status(status, cwd)
|
||||
local direct = {}
|
||||
for p, s in pairs(status) do
|
||||
---@return GitProjectDirs
|
||||
function M.project_files_to_project_dirs(project_files, cwd)
|
||||
---@type GitProjectDirs
|
||||
local project_dirs = {}
|
||||
|
||||
project_dirs.direct = {}
|
||||
for p, s in pairs(project_files) do
|
||||
if s ~= "!!" then
|
||||
local modified = vim.fn.fnamemodify(p, ":h")
|
||||
direct[modified] = nil_insert(direct[modified], s)
|
||||
project_dirs.direct[modified] = nil_insert(project_dirs.direct[modified], s)
|
||||
end
|
||||
end
|
||||
|
||||
local indirect = {}
|
||||
for dirname, statuses in pairs(direct) do
|
||||
project_dirs.indirect = {}
|
||||
for dirname, statuses in pairs(project_dirs.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)
|
||||
project_dirs.indirect[modified] = nil_insert(project_dirs.indirect[modified], s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local r = { indirect = indirect, direct = direct }
|
||||
for _, d in pairs(r) do
|
||||
for _, d in pairs(project_dirs) do
|
||||
for dirname, statuses in pairs(d) do
|
||||
local new_statuses = {}
|
||||
for s, _ in pairs(statuses) do
|
||||
@@ -123,7 +126,60 @@ function M.file_status_to_dir_status(status, cwd)
|
||||
d[dirname] = new_statuses
|
||||
end
|
||||
end
|
||||
return r
|
||||
|
||||
return project_dirs
|
||||
end
|
||||
|
||||
---Git file status for an absolute path
|
||||
---@param parent_ignored boolean
|
||||
---@param project GitProject?
|
||||
---@param path string
|
||||
---@param path_fallback string? alternative file path when no other file status
|
||||
---@return GitNodeStatus
|
||||
function M.git_status_file(parent_ignored, project, path, path_fallback)
|
||||
---@type GitNodeStatus
|
||||
local ns
|
||||
|
||||
if parent_ignored then
|
||||
ns = {
|
||||
file = "!!"
|
||||
}
|
||||
elseif project and project.files then
|
||||
ns = {
|
||||
file = project.files[path] or project.files[path_fallback]
|
||||
}
|
||||
else
|
||||
ns = {}
|
||||
end
|
||||
|
||||
return ns
|
||||
end
|
||||
|
||||
---Git file and directory status for an absolute path
|
||||
---@param parent_ignored boolean
|
||||
---@param project GitProject?
|
||||
---@param path string
|
||||
---@param path_fallback string? alternative file path when no other file status
|
||||
---@return GitNodeStatus?
|
||||
function M.git_status_dir(parent_ignored, project, path, path_fallback)
|
||||
---@type GitNodeStatus?
|
||||
local ns
|
||||
|
||||
if parent_ignored then
|
||||
ns = {
|
||||
file = "!!"
|
||||
}
|
||||
elseif project then
|
||||
ns = {
|
||||
file = project.files and (project.files[path] or project.files[path_fallback]),
|
||||
dir = project.dirs and {
|
||||
direct = project.dirs.direct and project.dirs.direct[path],
|
||||
indirect = project.dirs.indirect and project.dirs.indirect[path],
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return ns
|
||||
end
|
||||
|
||||
function M.setup(opts)
|
||||
|
||||
Reference in New Issue
Block a user