committed by
GitHub
parent
9066cbf3f7
commit
7629d4d106
@@ -216,6 +216,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
|
|||||||
all = false,
|
all = false,
|
||||||
config = false,
|
config = false,
|
||||||
copy_paste = false,
|
copy_paste = false,
|
||||||
|
diagnostics = false,
|
||||||
git = false,
|
git = false,
|
||||||
profile = false,
|
profile = false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ function.
|
|||||||
all = false,
|
all = false,
|
||||||
config = false,
|
config = false,
|
||||||
copy_paste = false,
|
copy_paste = false,
|
||||||
|
diagnostics = false,
|
||||||
git = false,
|
git = false,
|
||||||
profile = false,
|
profile = false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -410,6 +410,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
all = false,
|
all = false,
|
||||||
config = false,
|
config = false,
|
||||||
copy_paste = false,
|
copy_paste = false,
|
||||||
|
diagnostics = false,
|
||||||
git = false,
|
git = false,
|
||||||
profile = false,
|
profile = false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local a = vim.api
|
|||||||
local utils = require "nvim-tree.utils"
|
local utils = require "nvim-tree.utils"
|
||||||
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 log = require "nvim-tree.log"
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@@ -124,6 +125,9 @@ function M.update()
|
|||||||
if not M.enable or not core.get_explorer() or not view.is_buf_valid(view.get_bufnr()) then
|
if not M.enable or not core.get_explorer() or not view.is_buf_valid(view.get_bufnr()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local ps = log.profile_start "diagnostics update"
|
||||||
|
log.line("diagnostics", "update")
|
||||||
|
|
||||||
local buffer_severity
|
local buffer_severity
|
||||||
if is_using_coc() then
|
if is_using_coc() then
|
||||||
buffer_severity = from_coc()
|
buffer_severity = from_coc()
|
||||||
@@ -133,19 +137,25 @@ function M.update()
|
|||||||
|
|
||||||
M.clear()
|
M.clear()
|
||||||
for bufname, severity in pairs(buffer_severity) do
|
for bufname, severity in pairs(buffer_severity) do
|
||||||
|
local bufpath = utils.canonical_path(bufname)
|
||||||
|
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 node, line = utils.find_node(core.get_explorer().nodes, function(node)
|
||||||
|
local nodepath = utils.canonical_path(node.absolute_path)
|
||||||
|
log.line("diagnostics", " checking nodepath '%s'", nodepath)
|
||||||
if M.show_on_dirs and not node.open then
|
if M.show_on_dirs and not node.open then
|
||||||
return vim.startswith(bufname, node.absolute_path)
|
return vim.startswith(bufpath, nodepath)
|
||||||
else
|
else
|
||||||
return node.absolute_path == bufname
|
return nodepath == bufpath
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
if node then
|
if node then
|
||||||
|
log.line("diagnostics", " matched node '%s'", node.absolute_path)
|
||||||
add_sign(line, severity)
|
add_sign(line, severity)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
log.profile_end(ps, "diagnostics update")
|
||||||
end
|
end
|
||||||
|
|
||||||
local has_06 = vim.fn.has "nvim-0.6" == 1
|
local has_06 = vim.fn.has "nvim-0.6" == 1
|
||||||
@@ -170,8 +180,10 @@ function M.setup(opts)
|
|||||||
|
|
||||||
if M.enable then
|
if M.enable then
|
||||||
if has_06 then
|
if has_06 then
|
||||||
|
log.line("diagnostics", "setup has_06")
|
||||||
vim.cmd "au DiagnosticChanged * lua require'nvim-tree.diagnostics'.update()"
|
vim.cmd "au DiagnosticChanged * lua require'nvim-tree.diagnostics'.update()"
|
||||||
else
|
else
|
||||||
|
log.line("diagnostics", "setup not has_06")
|
||||||
vim.cmd "au User LspDiagnosticsChanged lua require'nvim-tree.diagnostics'.update()"
|
vim.cmd "au User LspDiagnosticsChanged lua require'nvim-tree.diagnostics'.update()"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user