typechecked optargs constructors for decorators, WIP
This commit is contained in:
@@ -5,31 +5,28 @@ local Decorator = require("nvim-tree.renderer.decorator")
|
||||
|
||||
---@class (exact) DecoratorBookmarks: Decorator
|
||||
---@field icon HighlightedString?
|
||||
local DecoratorBookmarks = Decorator:new()
|
||||
local DecoratorBookmarks = Decorator:extend()
|
||||
|
||||
---Static factory method
|
||||
---@param opts table
|
||||
---@param explorer Explorer
|
||||
---@return DecoratorBookmarks
|
||||
function DecoratorBookmarks:create(opts, explorer)
|
||||
---@type DecoratorBookmarks
|
||||
local o = {
|
||||
explorer = explorer,
|
||||
enabled = true,
|
||||
hl_pos = HL_POSITION[opts.renderer.highlight_bookmarks] or HL_POSITION.none,
|
||||
icon_placement = ICON_PLACEMENT[opts.renderer.icons.bookmarks_placement] or ICON_PLACEMENT.none,
|
||||
}
|
||||
o = self:new(o)
|
||||
---@class DecoratorBookmarks
|
||||
---@overload fun(explorer: DecoratorArgs): DecoratorBookmarks
|
||||
|
||||
if opts.renderer.icons.show.bookmarks then
|
||||
o.icon = {
|
||||
str = opts.renderer.icons.glyphs.bookmark,
|
||||
---@private
|
||||
---@param args DecoratorArgs
|
||||
function DecoratorBookmarks:new(args)
|
||||
Decorator.new(self, {
|
||||
explorer = args.explorer,
|
||||
enabled = true,
|
||||
hl_pos = HL_POSITION[args.explorer.opts.renderer.highlight_bookmarks] or HL_POSITION.none,
|
||||
icon_placement = ICON_PLACEMENT[args.explorer.opts.renderer.icons.bookmarks_placement] or ICON_PLACEMENT.none,
|
||||
})
|
||||
|
||||
if self.explorer.opts.renderer.icons.show.bookmarks then
|
||||
self.icon = {
|
||||
str = self.explorer.opts.renderer.icons.glyphs.bookmark,
|
||||
hl = { "NvimTreeBookmarkIcon" },
|
||||
}
|
||||
o:define_sign(o.icon)
|
||||
self:define_sign(self.icon)
|
||||
end
|
||||
|
||||
return o
|
||||
end
|
||||
|
||||
---Bookmark icon: renderer.icons.show.bookmarks and node is marked
|
||||
|
||||
Reference in New Issue
Block a user