* 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>
69 lines
1.2 KiB
Lua
69 lines
1.2 KiB
Lua
local renderer = {} -- circular dependency
|
|
|
|
local NvimTreeMarks = {}
|
|
|
|
local M = {}
|
|
|
|
---@class MinimalNode
|
|
---@field absolute_path string
|
|
|
|
---@param node Node|MinimalNode
|
|
local function add_mark(node)
|
|
NvimTreeMarks[node.absolute_path] = node
|
|
|
|
renderer.draw()
|
|
end
|
|
|
|
---@param node Node|MinimalNode
|
|
local function remove_mark(node)
|
|
NvimTreeMarks[node.absolute_path] = nil
|
|
|
|
renderer.draw()
|
|
end
|
|
|
|
---@param node Node|MinimalNode
|
|
function M.toggle_mark(node)
|
|
if node.absolute_path == nil then
|
|
return
|
|
end
|
|
|
|
if M.get_mark(node) then
|
|
remove_mark(node)
|
|
else
|
|
add_mark(node)
|
|
end
|
|
|
|
renderer.draw()
|
|
end
|
|
|
|
function M.clear_marks()
|
|
NvimTreeMarks = {}
|
|
|
|
renderer.draw()
|
|
end
|
|
|
|
---@param node Node|MinimalNode
|
|
---@return table|nil
|
|
function M.get_mark(node)
|
|
return node and NvimTreeMarks[node.absolute_path]
|
|
end
|
|
|
|
---@return table
|
|
function M.get_marks()
|
|
local list = {}
|
|
for _, node in pairs(NvimTreeMarks) do
|
|
table.insert(list, node)
|
|
end
|
|
return list
|
|
end
|
|
|
|
function M.setup(opts)
|
|
renderer = require "nvim-tree.renderer"
|
|
|
|
require("nvim-tree.marks.bulk-delete").setup(opts)
|
|
require("nvim-tree.marks.bulk-trash").setup(opts)
|
|
require("nvim-tree.marks.bulk-move").setup(opts)
|
|
end
|
|
|
|
return M
|