local HL_POSITION = require("nvim-tree.enum").HL_POSITION local ICON_PLACEMENT = require("nvim-tree.enum").ICON_PLACEMENT local Decorator = require("nvim-tree.renderer.decorator") ---@class (exact) DecoratorBookmarks: Decorator ---@field icon HighlightedString? local DecoratorBookmarks = Decorator:extend() ---@class DecoratorBookmarks ---@overload fun(explorer: DecoratorArgs): DecoratorBookmarks ---@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" }, } self:define_sign(self.icon) end end ---Bookmark icon: renderer.icons.show.bookmarks and node is marked ---@param node Node ---@return HighlightedString[]|nil icons function DecoratorBookmarks:calculate_icons(node) if self.explorer.marks:get(node) then return { self.icon } end end ---Bookmark highlight: renderer.highlight_bookmarks and node is marked ---@param node Node ---@return string|nil group function DecoratorBookmarks:calculate_highlight(node) if self.hl_pos ~= HL_POSITION.none and self.explorer.marks:get(node) then return "NvimTreeBookmarkHL" end end return DecoratorBookmarks