* feat(#2948): add UserDecorator, proof of concept * feat(#2948): add UserDecorator, proof of concept * feat(#2948): add UserDecorator, proof of concept * feat(#2948): add UserDecorator * feat(#2948): add UserDecorator * feat(#2948): add UserDecorator * feat(#2948): add Decorator node icon override * feat(#2948): add nvim_tree.api.* node classes * feat(#2948): extract _meta following nvim pattern * feat(#2948): extract _meta following nvim pattern * feat(#2948): add decorator registry and order * feat(#2948): add decorator registry and order * feat(#2948): tidy * feat(#2948): document API * feat(#2948): document API * feat(#2948): document API * feat(#2948): pass api nodes to user decorators * feat(#2948): document API * feat(#2948): use renderer.decorators to define order and register * feat(#2948): tidy decorator args and complete documentation * feat(#2948): decorator classes specified by prefix rather than suffix * feat(#2948): improve doc * feat(#2948): improve doc * feat(#2948): improve doc * feat(#2948): additional user decorator safety * feat(#2948): create nvim_tree.api.decorator.UserDecorator class in API, add :extend * feat(#2948): improve doc
This commit is contained in:
committed by
GitHub
parent
ca7c4c33ca
commit
7a4ff1a516
@@ -1,29 +1,29 @@
|
||||
local Decorator = require("nvim-tree.renderer.decorator")
|
||||
|
||||
---@class (exact) DecoratorCut: Decorator
|
||||
local DecoratorCut = Decorator:extend()
|
||||
---@class (exact) CutDecorator: Decorator
|
||||
---@field private explorer Explorer
|
||||
local CutDecorator = Decorator:extend()
|
||||
|
||||
---@class DecoratorCut
|
||||
---@overload fun(explorer: DecoratorArgs): DecoratorCut
|
||||
---@class CutDecorator
|
||||
---@overload fun(args: DecoratorArgs): CutDecorator
|
||||
|
||||
---@protected
|
||||
---@param args DecoratorArgs
|
||||
function DecoratorCut:new(args)
|
||||
Decorator.new(self, {
|
||||
explorer = args.explorer,
|
||||
enabled = true,
|
||||
hl_pos = args.explorer.opts.renderer.highlight_clipboard or "none",
|
||||
icon_placement = "none",
|
||||
})
|
||||
function CutDecorator:new(args)
|
||||
self.explorer = args.explorer
|
||||
|
||||
self.enabled = true
|
||||
self.highlight_range = self.explorer.opts.renderer.highlight_clipboard or "none"
|
||||
self.icon_placement = "none"
|
||||
end
|
||||
|
||||
---Cut highlight: renderer.highlight_clipboard and node is cut
|
||||
---@param node Node
|
||||
---@return string|nil group
|
||||
function DecoratorCut:calculate_highlight(node)
|
||||
if self.range ~= "none" and self.explorer.clipboard:is_cut(node) then
|
||||
---@return string? highlight_group
|
||||
function CutDecorator:highlight_group(node)
|
||||
if self.highlight_range ~= "none" and self.explorer.clipboard:is_cut(node) then
|
||||
return "NvimTreeCutHL"
|
||||
end
|
||||
end
|
||||
|
||||
return DecoratorCut
|
||||
return CutDecorator
|
||||
|
||||
Reference in New Issue
Block a user