@@ -10,8 +10,12 @@
|
||||
-- change on the underlying filesystem.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--- @alias u.examples.FsDir { kind: 'dir'; path: string; expanded: boolean; children: u.examples.FsNode[] }
|
||||
--- @alias u.examples.FsFile { kind: 'file'; path: string }
|
||||
--- @class u.examples.FsDir
|
||||
--- @field kind 'dir'
|
||||
--- @field path string
|
||||
--- @field expanded boolean
|
||||
--- @field children u.examples.FsNode[]
|
||||
--- @alias u.examples.FsFile table
|
||||
--- @alias u.examples.FsNode u.examples.FsDir | u.examples.FsFile
|
||||
--- @alias u.examples.ShowOpts { root_path?: string, width?: number, focus_path?: string }
|
||||
|
||||
@@ -58,7 +62,7 @@ function H.relative(path, base)
|
||||
end
|
||||
|
||||
--- @param root_path string
|
||||
--- @return { tree: u.examples.FsDir; path_to_node: table<string, u.examples.FsNode> }
|
||||
--- @return { tree: u.examples.FsDir, path_to_node: table<string, u.examples.FsNode> }
|
||||
function H.get_tree_inf(root_path)
|
||||
logger:info { 'get_tree_inf', root_path }
|
||||
--- @type table<string, u.examples.FsNode>
|
||||
@@ -112,12 +116,11 @@ function H.populate_dir_children(tree, path_to_node)
|
||||
end)
|
||||
end
|
||||
|
||||
--- @param opts {
|
||||
--- bufnr: number;
|
||||
--- prev_winnr: number;
|
||||
--- root_path: string;
|
||||
--- focus_path?: string;
|
||||
--- }
|
||||
--- @class u.examples.RenderOpts
|
||||
--- @field bufnr number
|
||||
--- @field prev_winnr number
|
||||
--- @field root_path string
|
||||
--- @field focus_path? string
|
||||
---
|
||||
--- @return { expand: fun(path: string), collapse: fun(path: string) }
|
||||
local function _render_in_buffer(opts)
|
||||
@@ -310,7 +313,7 @@ local function _render_in_buffer(opts)
|
||||
--
|
||||
local renderer = Renderer.new(opts.bufnr)
|
||||
tracker.create_effect(function()
|
||||
--- @type { tree: u.examples.FsDir; path_to_node: table<string, u.examples.FsNode> }
|
||||
--- @type { tree: u.examples.FsDir, path_to_node: table<string, u.examples.FsNode> }
|
||||
local tree_inf = s_tree_inf:get()
|
||||
local tree = tree_inf.tree
|
||||
|
||||
@@ -406,11 +409,10 @@ end
|
||||
-- Public API functions:
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--- @type {
|
||||
--- bufnr: number;
|
||||
--- winnr: number;
|
||||
--- controller: { expand: fun(path: string), collapse: fun(path: string) };
|
||||
--- } | nil
|
||||
--- @class u.examples.CurrentInf
|
||||
--- @field bufnr number
|
||||
--- @field winnr number
|
||||
--- @field controller table
|
||||
local current_inf = nil
|
||||
|
||||
--- Show the filetree:
|
||||
|
||||
Reference in New Issue
Block a user