typechecked optargs constructors for decorators

This commit is contained in:
Alexander Courtis
2024-11-08 10:57:53 +11:00
parent b092915f17
commit f6392cf88a
4 changed files with 55 additions and 64 deletions

View File

@@ -7,23 +7,20 @@ local Decorator = require("nvim-tree.renderer.decorator")
---@class (exact) DecoratorOpened: Decorator
---@field icon HighlightedString|nil
local DecoratorOpened = Decorator:new()
local DecoratorOpened = Decorator:extend()
---Static factory method
---@param opts table
---@param explorer Explorer
---@return DecoratorOpened
function DecoratorOpened:create(opts, explorer)
---@type DecoratorOpened
local o = {
explorer = explorer,
enabled = true,
hl_pos = HL_POSITION[opts.renderer.highlight_opened_files] or HL_POSITION.none,
---@class DecoratorOpened
---@overload fun(explorer: DecoratorArgs): DecoratorOpened
---@private
---@param args DecoratorArgs
function DecoratorOpened:new(args)
Decorator.new(self, {
explorer = args.explorer,
enabled = true,
hl_pos = HL_POSITION[args.explorer.opts.renderer.highlight_opened_files] or HL_POSITION.none,
icon_placement = ICON_PLACEMENT.none,
}
o = self:new(o)
return o
})
end
---Opened highlight: renderer.highlight_opened_files and node has an open buffer