feat(#2948): add UserDecorator
This commit is contained in:
parent
24eb27ebba
commit
f2a926d608
@ -16,11 +16,6 @@ local DecoratorOpened = require("nvim-tree.renderer.decorator.opened")
|
|||||||
|
|
||||||
local pad = require("nvim-tree.renderer.components.padding")
|
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
|
---@class (exact) AddHighlightArgs
|
||||||
---@field group string[]
|
---@field group string[]
|
||||||
---@field line number
|
---@field line number
|
||||||
|
|||||||
@ -11,3 +11,8 @@
|
|||||||
---@field enabled boolean
|
---@field enabled boolean
|
||||||
---@field highlight_range DecoratorHighlightRange
|
---@field highlight_range DecoratorHighlightRange
|
||||||
---@field icon_placement DecoratorIconPlacement
|
---@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[]
|
||||||
|
|||||||
@ -2,7 +2,7 @@ local Decorator = require("nvim-tree.renderer.decorator")
|
|||||||
|
|
||||||
---Abstract user decorator, extend to define your own.
|
---Abstract user decorator, extend to define your own.
|
||||||
---Icon and highlight are optional.
|
---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 super passing DecoratorArgs: MyDecorator.super.new(self, args)
|
||||||
--- Must call define_sign, when using "signcolumn"
|
--- Must call define_sign, when using "signcolumn"
|
||||||
---See example at end.
|
---See example at end.
|
||||||
@ -10,7 +10,7 @@ local Decorator = require("nvim-tree.renderer.decorator")
|
|||||||
---@class (exact) UserDecorator: Decorator
|
---@class (exact) UserDecorator: Decorator
|
||||||
local UserDecorator = Decorator:extend()
|
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
|
---@param node Node
|
||||||
---@return HighlightedString[]? icons
|
---@return HighlightedString[]? icons
|
||||||
function UserDecorator:calculate_icons(node)
|
function UserDecorator:calculate_icons(node)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user