* 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>
51 lines
1.2 KiB
Lua
51 lines
1.2 KiB
Lua
local M = {}
|
|
|
|
---@type table<string, boolean> record of which file is modified
|
|
M._modified = {}
|
|
|
|
---refresh M._modified
|
|
function M.reload_modified()
|
|
M._modified = {}
|
|
local bufs = vim.fn.getbufinfo { bufmodified = true, buflisted = true }
|
|
for _, buf in pairs(bufs) do
|
|
local path = buf.name
|
|
if path ~= "" then -- not a [No Name] buffer
|
|
-- mark all the parent as modified as well
|
|
while
|
|
M._modified[path] ~= true
|
|
-- no need to keep going if already recorded
|
|
-- This also prevents an infinite loop
|
|
do
|
|
M._modified[path] = true
|
|
path = vim.fn.fnamemodify(path, ":h")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---@param node table
|
|
---@return boolean
|
|
function M.is_modified(node)
|
|
return node
|
|
and M.config.modified.enable
|
|
and M._modified[node.absolute_path]
|
|
and (not node.nodes or M.config.modified.show_on_dirs)
|
|
and (not node.open or M.config.modified.show_on_open_dirs)
|
|
end
|
|
|
|
---A buffer exists for the node's absolute path
|
|
---@param node table
|
|
---@return boolean
|
|
function M.is_opened(node)
|
|
return node and vim.fn.bufloaded(node.absolute_path) > 0
|
|
end
|
|
|
|
---@param opts table
|
|
function M.setup(opts)
|
|
M.config = {
|
|
modified = opts.modified,
|
|
}
|
|
end
|
|
|
|
return M
|