* 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>
62 lines
1.7 KiB
Lua
62 lines
1.7 KiB
Lua
local buffers = require "nvim-tree.buffers"
|
|
|
|
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 DecoratorModified: Decorator
|
|
---@field icon HighlightedString|nil
|
|
local DecoratorModified = Decorator:new()
|
|
|
|
---@param opts table
|
|
---@return DecoratorModified
|
|
function DecoratorModified:new(opts)
|
|
local o = Decorator.new(self, {
|
|
enabled = opts.modified.enable,
|
|
hl_pos = HL_POSITION[opts.renderer.highlight_modified] or HL_POSITION.none,
|
|
icon_placement = ICON_PLACEMENT[opts.renderer.icons.modified_placement] or ICON_PLACEMENT.none,
|
|
})
|
|
---@cast o DecoratorModified
|
|
|
|
if not o.enabled then
|
|
return o
|
|
end
|
|
|
|
if opts.renderer.icons.show.modified then
|
|
o.icon = {
|
|
str = opts.renderer.icons.glyphs.modified,
|
|
hl = { "NvimTreeModifiedIcon" },
|
|
}
|
|
o:define_sign(o.icon)
|
|
end
|
|
|
|
return o
|
|
end
|
|
|
|
---Modified icon: modified.enable, renderer.icons.show.modified and node is modified
|
|
---@param node Node
|
|
---@return HighlightedString[]|nil icons
|
|
function DecoratorModified:calculate_icons(node)
|
|
if self.enabled and buffers.is_modified(node) then
|
|
return { self.icon }
|
|
end
|
|
end
|
|
|
|
---Modified highlight: modified.enable, renderer.highlight_modified and node is modified
|
|
---@param node Node
|
|
---@return string|nil group
|
|
function DecoratorModified:calculate_highlight(node)
|
|
if not self.enabled or self.hl_pos == HL_POSITION.none or not buffers.is_modified(node) then
|
|
return nil
|
|
end
|
|
|
|
if node.nodes then
|
|
return "NvimTreeModifiedFolderHL"
|
|
else
|
|
return "NvimTreeModifiedFileHL"
|
|
end
|
|
end
|
|
|
|
return DecoratorModified
|