#1091 diagnostics logging (#1170)

This commit is contained in:
Alexander Courtis 2022-04-18 23:39:51 +10:00 committed by GitHub
parent 9066cbf3f7
commit 7629d4d106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View File

@ -216,6 +216,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
all = false,
config = false,
copy_paste = false,
diagnostics = false,
git = false,
profile = false,
},

View File

@ -185,6 +185,7 @@ function.
all = false,
config = false,
copy_paste = false,
diagnostics = false,
git = false,
profile = false,
},

View File

@ -410,6 +410,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
all = false,
config = false,
copy_paste = false,
diagnostics = false,
git = false,
profile = false,
},

View File

@ -2,6 +2,7 @@ local a = vim.api
local utils = require "nvim-tree.utils"
local view = require "nvim-tree.view"
local core = require "nvim-tree.core"
local log = require "nvim-tree.log"
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
return
end
local ps = log.profile_start "diagnostics update"
log.line("diagnostics", "update")
local buffer_severity
if is_using_coc() then
buffer_severity = from_coc()
@ -133,19 +137,25 @@ function M.update()
M.clear()
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
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
return vim.startswith(bufname, node.absolute_path)
return vim.startswith(bufpath, nodepath)
else
return node.absolute_path == bufname
return nodepath == bufpath
end
end)
if node then
log.line("diagnostics", " matched node '%s'", node.absolute_path)
add_sign(line, severity)
end
end
end
log.profile_end(ps, "diagnostics update")
end
local has_06 = vim.fn.has "nvim-0.6" == 1
@ -170,8 +180,10 @@ function M.setup(opts)
if M.enable then
if has_06 then
log.line("diagnostics", "setup has_06")
vim.cmd "au DiagnosticChanged * lua require'nvim-tree.diagnostics'.update()"
else
log.line("diagnostics", "setup not has_06")
vim.cmd "au User LspDiagnosticsChanged lua require'nvim-tree.diagnostics'.update()"
end
end