Skip to content

Commit 7629d4d

Browse files
authored
#1091 diagnostics logging (#1170)
1 parent 9066cbf commit 7629d4d

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS
216216
all = false,
217217
config = false,
218218
copy_paste = false,
219+
diagnostics = false,
219220
git = false,
220221
profile = false,
221222
},

doc/nvim-tree-lua.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ function.
185185
all = false,
186186
config = false,
187187
copy_paste = false,
188+
diagnostics = false,
188189
git = false,
189190
profile = false,
190191
},

lua/nvim-tree.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
410410
all = false,
411411
config = false,
412412
copy_paste = false,
413+
diagnostics = false,
413414
git = false,
414415
profile = false,
415416
},

lua/nvim-tree/diagnostics.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local a = vim.api
22
local utils = require "nvim-tree.utils"
33
local view = require "nvim-tree.view"
44
local core = require "nvim-tree.core"
5+
local log = require "nvim-tree.log"
56

67
local M = {}
78

@@ -124,6 +125,9 @@ function M.update()
124125
if not M.enable or not core.get_explorer() or not view.is_buf_valid(view.get_bufnr()) then
125126
return
126127
end
128+
local ps = log.profile_start "diagnostics update"
129+
log.line("diagnostics", "update")
130+
127131
local buffer_severity
128132
if is_using_coc() then
129133
buffer_severity = from_coc()
@@ -133,19 +137,25 @@ function M.update()
133137

134138
M.clear()
135139
for bufname, severity in pairs(buffer_severity) do
140+
local bufpath = utils.canonical_path(bufname)
141+
log.line("diagnostics", " bufpath '%s' severity %d", bufpath, severity)
136142
if 0 < severity and severity < 5 then
137143
local node, line = utils.find_node(core.get_explorer().nodes, function(node)
144+
local nodepath = utils.canonical_path(node.absolute_path)
145+
log.line("diagnostics", " checking nodepath '%s'", nodepath)
138146
if M.show_on_dirs and not node.open then
139-
return vim.startswith(bufname, node.absolute_path)
147+
return vim.startswith(bufpath, nodepath)
140148
else
141-
return node.absolute_path == bufname
149+
return nodepath == bufpath
142150
end
143151
end)
144152
if node then
153+
log.line("diagnostics", " matched node '%s'", node.absolute_path)
145154
add_sign(line, severity)
146155
end
147156
end
148157
end
158+
log.profile_end(ps, "diagnostics update")
149159
end
150160

151161
local has_06 = vim.fn.has "nvim-0.6" == 1
@@ -170,8 +180,10 @@ function M.setup(opts)
170180

171181
if M.enable then
172182
if has_06 then
183+
log.line("diagnostics", "setup has_06")
173184
vim.cmd "au DiagnosticChanged * lua require'nvim-tree.diagnostics'.update()"
174185
else
186+
log.line("diagnostics", "setup not has_06")
175187
vim.cmd "au User LspDiagnosticsChanged lua require'nvim-tree.diagnostics'.update()"
176188
end
177189
end

0 commit comments

Comments
 (0)