* feat(#2415): granular highlight_diagnostics, normalise groups (#2454) * chore: normalise colours and enable cterm (#2471) * feat(#2415): granular highlight_git, normalise git groups (#2487) * docs: update CONTRIBUTING.md (#2485) * feat(#2415): granular highlight_git, normalise git groups * feat(#2415): normalise and add modified groups * feat(#2415): create Decorator class for modified and bookmarks * feat(#2415): create DecoratorDiagnostics * feat(#2415): create DecoratorGit * feat(#2415): create DecoratorGit * add DecoratorCopied DecoratorCut * add DecoratorOpened * remove unloaded_bufnr checks as the view debouncer takes care of it * Add `renderer.highlight_git` to accepted strings * fix(#2415): builder refactor (#2538) * simplify builder signs * decorators take care of themselves and are priority ordered * simplify builder hl groups * refactor builder for icon arrays * builder use decorators generically * fix(#2415): harden sign creation (#2539) * fix(#2415): harden unicode signs * Decorator tidy * normalise git sign creation and tidy * tidy builder * NvimTreeBookmarkIcon * tidy HL doc * tidy HL doc * tidy HL doc * tidy builder doc * standardise on '---@param' * DiagnosticWarning -> DiagnosticWarn * annotate decorators * limit to two highlight groups for line rendering * style * apply #2519 * feat(#2415): combined hl groups (#2601) * feat(#2415): create combined highlight groups * feat(#2415): create combined highlight groups * feat(#2415): create combined highlight groups * ci: allow workflow_dispatch (#2620) * one and only one hl namespace, required winhl removal * small tidies * colors.lua -> appearance.lua * full-name uses one and only namespace * don't highlight fast, just apply to namespace, safer win_set_hl * gut builder (#2622) collapse Builder * fix group_empty function check * feat(#2415): highlight-overhaul release date --------- Co-authored-by: Akmadan23 <azadahmadi@mailo.com>
52 lines
1.4 KiB
Lua
52 lines
1.4 KiB
Lua
local marks = require "nvim-tree.marks"
|
|
|
|
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 DecoratorBookmarks: Decorator
|
|
---@field icon HighlightedString
|
|
local DecoratorBookmarks = Decorator:new()
|
|
|
|
---@param opts table
|
|
---@return DecoratorBookmarks
|
|
function DecoratorBookmarks:new(opts)
|
|
local o = Decorator.new(self, {
|
|
enabled = true,
|
|
hl_pos = HL_POSITION[opts.renderer.highlight_bookmarks] or HL_POSITION.none,
|
|
icon_placement = ICON_PLACEMENT[opts.renderer.icons.bookmarks_placement] or ICON_PLACEMENT.none,
|
|
})
|
|
---@cast o DecoratorBookmarks
|
|
|
|
if opts.renderer.icons.show.bookmarks then
|
|
o.icon = {
|
|
str = opts.renderer.icons.glyphs.bookmark,
|
|
hl = { "NvimTreeBookmarkIcon" },
|
|
}
|
|
o:define_sign(o.icon)
|
|
end
|
|
|
|
return o
|
|
end
|
|
|
|
---Bookmark icon: renderer.icons.show.bookmarks and node is marked
|
|
---@param node Node
|
|
---@return HighlightedString[]|nil icons
|
|
function DecoratorBookmarks:calculate_icons(node)
|
|
if marks.get_mark(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 marks.get_mark(node) then
|
|
return "NvimTreeBookmarkHL"
|
|
end
|
|
end
|
|
|
|
return DecoratorBookmarks
|