refactor(marks): fix offset line and move into init.lua
also set node in marks record instead of true
This commit is contained in:
parent
078a9e5bf9
commit
6a49a0301f
@ -1262,6 +1262,6 @@ You can toggle marks on files/folders with
|
|||||||
default.
|
default.
|
||||||
|
|
||||||
To get the list of marked paths, you can call
|
To get the list of marked paths, you can call
|
||||||
`require("nvim-tree.marks").get_marks()`. This will return `{string}`.
|
`require("nvim-tree.marks").get_marks()`. This will return `{node}`.
|
||||||
|
|
||||||
vim:tw=78:ts=4:sw=4:et:ft=help:norl:
|
vim:tw=78:ts=4:sw=4:et:ft=help:norl:
|
||||||
|
|||||||
@ -7,7 +7,7 @@ local NvimTreeMarks = {}
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function add_mark(node)
|
local function add_mark(node)
|
||||||
NvimTreeMarks[node.absolute_path] = true
|
NvimTreeMarks[node.absolute_path] = node
|
||||||
M.draw()
|
M.draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ end
|
|||||||
|
|
||||||
function M.get_marks()
|
function M.get_marks()
|
||||||
local list = {}
|
local list = {}
|
||||||
for k in pairs(NvimTreeMarks) do
|
for _, node in pairs(NvimTreeMarks) do
|
||||||
table.insert(list, k)
|
table.insert(list, node)
|
||||||
end
|
end
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
@ -51,13 +51,14 @@ function M.draw()
|
|||||||
M.clear()
|
M.clear()
|
||||||
|
|
||||||
local buf = view.get_bufnr()
|
local buf = view.get_bufnr()
|
||||||
|
local add = core.get_nodes_starting_line() - 1
|
||||||
Iterator.builder(core.get_explorer().nodes)
|
Iterator.builder(core.get_explorer().nodes)
|
||||||
:recursor(function(node)
|
:recursor(function(node)
|
||||||
return node.open and node.nodes
|
return node.open and node.nodes
|
||||||
end)
|
end)
|
||||||
:applier(function(node, idx)
|
:applier(function(node, idx)
|
||||||
if M.get_mark(node) then
|
if M.get_mark(node) then
|
||||||
vim.fn.sign_place(0, GROUP, SIGN_NAME, buf, { lnum = idx + 1, priority = 3 })
|
vim.fn.sign_place(0, GROUP, SIGN_NAME, buf, { lnum = idx + add, priority = 3 })
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
:iterate()
|
:iterate()
|
||||||
Loading…
Reference in New Issue
Block a user