committed by
GitHub
parent
47732b6dbf
commit
82ec79aac5
@@ -105,7 +105,7 @@ end
|
|||||||
function M.find_git_item(where)
|
function M.find_git_item(where)
|
||||||
return function()
|
return function()
|
||||||
local node_cur = lib.get_node_at_cursor()
|
local node_cur = lib.get_node_at_cursor()
|
||||||
local nodes_by_line = lib.get_nodes_by_line(core.get_explorer().nodes, core.get_nodes_starting_line())
|
local nodes_by_line = utils.get_nodes_by_line(core.get_explorer().nodes, core.get_nodes_starting_line())
|
||||||
|
|
||||||
local cur, first, prev, nex = nil, nil, nil, nil
|
local cur, first, prev, nex = nil, nil, nil, nil
|
||||||
for line, node in pairs(nodes_by_line) do
|
for line, node in pairs(nodes_by_line) do
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ local function add_sign(linenr, severity)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local sign_name = sign_names[severity][1]
|
local sign_name = sign_names[severity][1]
|
||||||
vim.fn.sign_place(1, GROUP, sign_name, buf, { lnum = linenr + 1 })
|
vim.fn.sign_place(1, GROUP, sign_name, buf, { lnum = linenr })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function from_nvim_lsp()
|
local function from_nvim_lsp()
|
||||||
@@ -131,18 +131,17 @@ function M.update()
|
|||||||
local bufpath = utils.canonical_path(bufname)
|
local bufpath = utils.canonical_path(bufname)
|
||||||
log.line("diagnostics", " bufpath '%s' severity %d", bufpath, severity)
|
log.line("diagnostics", " bufpath '%s' severity %d", bufpath, severity)
|
||||||
if 0 < severity and severity < 5 then
|
if 0 < severity and severity < 5 then
|
||||||
local node, line = utils.find_node(core.get_explorer().nodes, function(node)
|
local nodes_by_line = utils.get_nodes_by_line(core.get_explorer().nodes, core.get_nodes_starting_line())
|
||||||
|
for line, node in pairs(nodes_by_line) do
|
||||||
local nodepath = utils.canonical_path(node.absolute_path)
|
local nodepath = utils.canonical_path(node.absolute_path)
|
||||||
log.line("diagnostics", " checking nodepath '%s'", nodepath)
|
log.line("diagnostics", " %d checking nodepath '%s'", line, nodepath)
|
||||||
if M.show_on_dirs and not node.open then
|
if M.show_on_dirs and vim.startswith(bufpath, nodepath) then
|
||||||
return vim.startswith(bufpath, nodepath)
|
log.line("diagnostics", " matched fold node '%s'", node.absolute_path)
|
||||||
else
|
|
||||||
return nodepath == bufpath
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
if node then
|
|
||||||
log.line("diagnostics", " matched node '%s'", node.absolute_path)
|
|
||||||
add_sign(line, severity)
|
add_sign(line, severity)
|
||||||
|
elseif nodepath == bufpath then
|
||||||
|
log.line("diagnostics", " matched file node '%s'", node.absolute_path)
|
||||||
|
add_sign(line, severity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,30 +3,12 @@ local api = vim.api
|
|||||||
local renderer = require "nvim-tree.renderer"
|
local renderer = require "nvim-tree.renderer"
|
||||||
local view = require "nvim-tree.view"
|
local view = require "nvim-tree.view"
|
||||||
local core = require "nvim-tree.core"
|
local core = require "nvim-tree.core"
|
||||||
|
local utils = require "nvim-tree.utils"
|
||||||
|
|
||||||
local M = {
|
local M = {
|
||||||
target_winid = nil,
|
target_winid = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.get_nodes_by_line(nodes_all, line_start)
|
|
||||||
local nodes_by_line = {}
|
|
||||||
local line = line_start
|
|
||||||
local function iter(nodes)
|
|
||||||
for _, node in ipairs(nodes) do
|
|
||||||
nodes_by_line[line] = node
|
|
||||||
line = line + 1
|
|
||||||
if node.open == true then
|
|
||||||
local child = iter(node.nodes)
|
|
||||||
if child ~= nil then
|
|
||||||
return child
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
iter(nodes_all)
|
|
||||||
return nodes_by_line
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.get_node_at_cursor()
|
function M.get_node_at_cursor()
|
||||||
if not core.get_explorer() then
|
if not core.get_explorer() then
|
||||||
return
|
return
|
||||||
@@ -39,14 +21,14 @@ function M.get_node_at_cursor()
|
|||||||
local line = cursor[1]
|
local line = cursor[1]
|
||||||
if view.is_help_ui() then
|
if view.is_help_ui() then
|
||||||
local help_lines = require("nvim-tree.renderer.help").compute_lines()
|
local help_lines = require("nvim-tree.renderer.help").compute_lines()
|
||||||
local help_text = M.get_nodes_by_line(help_lines, 1)[line]
|
local help_text = utils.get_nodes_by_line(help_lines, 1)[line]
|
||||||
return { name = help_text }
|
return { name = help_text }
|
||||||
else
|
else
|
||||||
if line == 1 and core.get_explorer().cwd ~= "/" and view.is_root_folder_visible() then
|
if line == 1 and core.get_explorer().cwd ~= "/" and view.is_root_folder_visible() then
|
||||||
return { name = ".." }
|
return { name = ".." }
|
||||||
end
|
end
|
||||||
|
|
||||||
return M.get_nodes_by_line(core.get_explorer().nodes, core.get_nodes_starting_line())[line]
|
return utils.get_nodes_by_line(core.get_explorer().nodes, core.get_nodes_starting_line())[line]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,29 @@ function M.find_node(nodes, fn)
|
|||||||
return node, i
|
return node, i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- return visible nodes indexed by line
|
||||||
|
-- @param nodes_all list of node
|
||||||
|
-- @param line_start first index
|
||||||
|
---@return table
|
||||||
|
function M.get_nodes_by_line(nodes_all, line_start)
|
||||||
|
local nodes_by_line = {}
|
||||||
|
local line = line_start
|
||||||
|
local function iter(nodes)
|
||||||
|
for _, node in ipairs(nodes) do
|
||||||
|
nodes_by_line[line] = node
|
||||||
|
line = line + 1
|
||||||
|
if node.open == true then
|
||||||
|
local child = iter(node.nodes)
|
||||||
|
if child ~= nil then
|
||||||
|
return child
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
iter(nodes_all)
|
||||||
|
return nodes_by_line
|
||||||
|
end
|
||||||
|
|
||||||
---Matching executable files in Windows.
|
---Matching executable files in Windows.
|
||||||
---@param ext string
|
---@param ext string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user