range: extmarks/tsquery; renderer: text-change
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m18s
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m18s
This commit is contained in:
@@ -10,10 +10,10 @@
|
||||
-- change on the underlying filesystem.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--- @alias FsDir { kind: 'dir'; path: string; expanded: boolean; children: FsNode[] }
|
||||
--- @alias FsFile { kind: 'file'; path: string }
|
||||
--- @alias FsNode FsDir | FsFile
|
||||
--- @alias ShowOpts { root_path?: string, width?: number, focus_path?: string }
|
||||
--- @alias u.examples.FsDir { kind: 'dir'; path: string; expanded: boolean; children: u.examples.FsNode[] }
|
||||
--- @alias u.examples.FsFile { kind: 'file'; path: string }
|
||||
--- @alias u.examples.FsNode u.examples.FsDir | u.examples.FsFile
|
||||
--- @alias u.examples.ShowOpts { root_path?: string, width?: number, focus_path?: string }
|
||||
|
||||
local Buffer = require 'u.buffer'
|
||||
local Renderer = require('u.renderer').Renderer
|
||||
@@ -58,13 +58,13 @@ function H.relative(path, base)
|
||||
end
|
||||
|
||||
--- @param root_path string
|
||||
--- @return { tree: FsDir; path_to_node: table<string, 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, FsNode>
|
||||
--- @type table<string, u.examples.FsNode>
|
||||
local path_to_node = {}
|
||||
|
||||
--- @type FsDir
|
||||
--- @type u.examples.FsDir
|
||||
local tree = {
|
||||
kind = 'dir',
|
||||
path = H.normalize(root_path or '.'),
|
||||
@@ -77,8 +77,8 @@ function H.get_tree_inf(root_path)
|
||||
return { tree = tree, path_to_node = path_to_node }
|
||||
end
|
||||
|
||||
--- @param tree FsDir
|
||||
--- @param path_to_node table<string, FsNode>
|
||||
--- @param tree u.examples.FsDir
|
||||
--- @param path_to_node table<string, u.examples.FsNode>
|
||||
function H.populate_dir_children(tree, path_to_node)
|
||||
tree.children = {}
|
||||
|
||||
@@ -135,7 +135,7 @@ local function _render_in_buffer(opts)
|
||||
local parts = H.split_path(H.relative(focused_path, tree_inf.tree.path))
|
||||
local path_to_node = tree_inf.path_to_node
|
||||
|
||||
--- @param node FsDir
|
||||
--- @param node u.examples.FsDir
|
||||
--- @param child_names string[]
|
||||
local function expand_to(node, child_names)
|
||||
if #child_names == 0 then return end
|
||||
@@ -310,7 +310,7 @@ local function _render_in_buffer(opts)
|
||||
--
|
||||
local renderer = Renderer.new(opts.bufnr)
|
||||
tracker.create_effect(function()
|
||||
--- @type { tree: FsDir; path_to_node: table<string, 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
|
||||
|
||||
@@ -329,7 +329,7 @@ local function _render_in_buffer(opts)
|
||||
|
||||
--- Since the filesystem is a recursive tree of nodes, we need to
|
||||
--- recursively render each node. This function does just that:
|
||||
--- @param node FsNode
|
||||
--- @param node u.examples.FsNode
|
||||
--- @param level number
|
||||
local function render_node(node, level)
|
||||
local name = vim.fs.basename(node.path)
|
||||
@@ -414,7 +414,7 @@ end
|
||||
local current_inf = nil
|
||||
|
||||
--- Show the filetree:
|
||||
--- @param opts? ShowOpts
|
||||
--- @param opts? u.examples.ShowOpts
|
||||
function M.show(opts)
|
||||
if current_inf ~= nil then return current_inf.controller end
|
||||
opts = opts or {}
|
||||
@@ -456,7 +456,7 @@ function M.hide()
|
||||
end
|
||||
|
||||
--- Toggle the filetree:
|
||||
--- @param opts? ShowOpts
|
||||
--- @param opts? u.examples.ShowOpts
|
||||
function M.toggle(opts)
|
||||
if current_inf == nil then
|
||||
M.show(opts)
|
||||
|
||||
Reference in New Issue
Block a user