* add classic, migrating nodes classes
* add mixins to classic
* typechecked optargs constructors for nodes
* typechecked optargs constructors for watcher and event
* luacheck
* typechecked optargs constructors for GitRunner
* typechecked optargs constructors for Sorter
* typechecked optargs constructors for decorators, WIP
* typechecked optargs constructors for decorators, WIP
* typechecked optargs constructors for decorators
* remove class
* replace enums with named maps
* Renderer and Builder use classic, tidy opts
* LiveFilter uses classic, tidy opts
* Filter uses classic, tidy opts
* add FilterTypes named map
* move toggles into filters
* Marks uses classic, tidy opts
* Sorter uses classic, tidy opts
* Clipboard uses classic, tidy opts
* use supers for node methods
* HighlightDisplay uses classic
* protected :new
* Watcher tidy
* Revert "use supers for node methods"
This reverts commit 9fc7a866ec.
* Watcher tidy
* format
* format
* Filters private methods
* format
* Sorter type safety
* Sorter type safety
* Sorter type safety
* Sorter type safety
* Sorter type safety
* Sorter type safety
* tidy Runner
* tidy hi-test name
72 lines
1.9 KiB
Lua
72 lines
1.9 KiB
Lua
local git_utils = require("nvim-tree.git.utils")
|
|
local utils = require("nvim-tree.utils")
|
|
|
|
local FileNode = require("nvim-tree.node.file")
|
|
local LinkNode = require("nvim-tree.node.link")
|
|
|
|
---@class (exact) FileLinkNode: FileNode, LinkNode
|
|
local FileLinkNode = FileNode:extend()
|
|
FileLinkNode:implement(LinkNode)
|
|
|
|
---@class FileLinkNode
|
|
---@overload fun(args: LinkNodeArgs): FileLinkNode
|
|
|
|
---@protected
|
|
---@param args LinkNodeArgs
|
|
function FileLinkNode:new(args)
|
|
LinkNode.new(self, args)
|
|
FileLinkNode.super.new(self, args)
|
|
|
|
self.type = "link"
|
|
end
|
|
|
|
function FileLinkNode:destroy()
|
|
FileNode.destroy(self)
|
|
end
|
|
|
|
---Update the git_status of the target otherwise the link itself
|
|
---@param parent_ignored boolean
|
|
---@param project GitProject?
|
|
function FileLinkNode:update_git_status(parent_ignored, project)
|
|
self.git_status = git_utils.git_status_file(parent_ignored, project, self.link_to, self.absolute_path)
|
|
end
|
|
|
|
---@return HighlightedString icon
|
|
function FileLinkNode:highlighted_icon()
|
|
if not self.explorer.opts.renderer.icons.show.file then
|
|
return self:highlighted_icon_empty()
|
|
end
|
|
|
|
local str, hl
|
|
|
|
-- default icon from opts
|
|
str = self.explorer.opts.renderer.icons.glyphs.symlink
|
|
hl = "NvimTreeSymlinkIcon"
|
|
|
|
return { str = str, hl = { hl } }
|
|
end
|
|
|
|
---@return HighlightedString name
|
|
function FileLinkNode:highlighted_name()
|
|
local str = self.name
|
|
if self.explorer.opts.renderer.symlink_destination then
|
|
local link_to = utils.path_relative(self.link_to, self.explorer.absolute_path)
|
|
str = string.format("%s%s%s", str, self.explorer.opts.renderer.icons.symlink_arrow, link_to)
|
|
end
|
|
|
|
return { str = str, hl = { "NvimTreeSymlink" } }
|
|
end
|
|
|
|
---Create a sanitized partial copy of a node
|
|
---@return FileLinkNode cloned
|
|
function FileLinkNode:clone()
|
|
local clone = FileNode.clone(self) --[[@as FileLinkNode]]
|
|
|
|
clone.link_to = self.link_to
|
|
clone.fs_stat_target = self.fs_stat_target
|
|
|
|
return clone
|
|
end
|
|
|
|
return FileLinkNode
|