nvim-tree.lua/lua/nvim-tree/marks/init.lua
Alexander Courtis d49a284236
feat(#2411): add renderer.highlight_bookmarks, renderer.icons.bookmarks_placement (#2412)
* feat(#1079): add highlight NvimTreeCopiedText and NvimTreeCutText

* feat(#1079): add highlight NvimTreeCopiedText and NvimTreeCutText

* feat(#1079): node may not be present in copy and cut

* feat(#2411): bookmark highlight and icon placement

* feat(#1079): add renderer.highlight_clipboard

* feat(#1079): add renderer.highlight_clipboard

* feat(#2411): bookmark highlight and icon placement

* feat(#2411): bookmark highlight and icon placement

* style

* feat(#2411): bookmark highlight and icon placement

* feat(#2411): bookmark highlight and icon placement

* feat(#2411): bookmark highlight and icon placement

* feat(#2411): bookmark highlight and icon placement
2023-09-24 15:07:02 +10:00

60 lines
984 B
Lua

local renderer = {} -- circular dependency
local NvimTreeMarks = {}
local M = {}
local function add_mark(node)
NvimTreeMarks[node.absolute_path] = node
renderer.draw()
end
local function remove_mark(node)
NvimTreeMarks[node.absolute_path] = nil
renderer.draw()
end
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
function M.get_mark(node)
return NvimTreeMarks[node.absolute_path]
end
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