Skip to content

Commit

Permalink
feat(#2948): add UserDecorator
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis committed Nov 22, 2024
1 parent 24eb27e commit f2a926d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 0 additions & 5 deletions lua/nvim-tree/renderer/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ local DecoratorOpened = require("nvim-tree.renderer.decorator.opened")

local pad = require("nvim-tree.renderer.components.padding")

---TODO move all these classes to API meta
---@class (exact) HighlightedString
---@field str string
---@field hl string[]

---@class (exact) AddHighlightArgs
---@field group string[]
---@field line number
Expand Down
5 changes: 5 additions & 0 deletions lua/nvim-tree/renderer/decorator/meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
---@field enabled boolean
---@field highlight_range DecoratorHighlightRange
---@field icon_placement DecoratorIconPlacement

---A string for rendering, with optional highlight groups to apply to it
---@class (exact) HighlightedString
---@field str string
---@field hl string[]
4 changes: 2 additions & 2 deletions lua/nvim-tree/renderer/decorator/user.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ local Decorator = require("nvim-tree.renderer.decorator")

---Abstract user decorator, extend to define your own.
---Icon and highlight are optional.
---Constructor will be called once per tree render, with no arguments:
---Mandatory constructor will be called once per tree render, with no arguments:
--- Must call super passing DecoratorArgs: MyDecorator.super.new(self, args)
--- Must call define_sign, when using "signcolumn"
---See example at end.

---@class (exact) UserDecorator: Decorator
local UserDecorator = Decorator:extend()

---Override this method to provide icons and the highlight groups to apply to them
---Override this method to provide icons and the highlight groups to apply to DecoratorIconPlacement
---@param node Node
---@return HighlightedString[]? icons
function UserDecorator:calculate_icons(node)
Expand Down

0 comments on commit f2a926d

Please sign in to comment.