@@ -90,43 +90,45 @@ function M.update()
9090 if not M .enable or not core .get_explorer () or not view .is_buf_valid (view .get_bufnr ()) then
9191 return
9292 end
93- local ps = log .profile_start " diagnostics update"
94- log .line (" diagnostics" , " update" )
95-
96- local buffer_severity
97- if is_using_coc () then
98- buffer_severity = from_coc ()
99- else
100- buffer_severity = from_nvim_lsp ()
101- end
93+ utils .debounce (" diagnostics" , M .debounce_delay , function ()
94+ local ps = log .profile_start " diagnostics update"
95+ log .line (" diagnostics" , " update" )
96+
97+ local buffer_severity
98+ if is_using_coc () then
99+ buffer_severity = from_coc ()
100+ else
101+ buffer_severity = from_nvim_lsp ()
102+ end
102103
103- M .clear ()
104+ M .clear ()
104105
105- local nodes_by_line = utils .get_nodes_by_line (core .get_explorer ().nodes , core .get_nodes_starting_line ())
106- for _ , node in pairs (nodes_by_line ) do
107- node .diag_status = nil
108- end
106+ local nodes_by_line = utils .get_nodes_by_line (core .get_explorer ().nodes , core .get_nodes_starting_line ())
107+ for _ , node in pairs (nodes_by_line ) do
108+ node .diag_status = nil
109+ end
109110
110- for bufname , severity in pairs (buffer_severity ) do
111- local bufpath = utils .canonical_path (bufname )
112- log .line (" diagnostics" , " bufpath '%s' severity %d" , bufpath , severity )
113- if 0 < severity and severity < 5 then
114- for line , node in pairs (nodes_by_line ) do
115- local nodepath = utils .canonical_path (node .absolute_path )
116- log .line (" diagnostics" , " %d checking nodepath '%s'" , line , nodepath )
117- if M .show_on_dirs and vim .startswith (bufpath , nodepath ) then
118- log .line (" diagnostics" , " matched fold node '%s'" , node .absolute_path )
119- node .diag_status = severity
120- add_sign (line , severity )
121- elseif nodepath == bufpath then
122- log .line (" diagnostics" , " matched file node '%s'" , node .absolute_path )
123- node .diag_status = severity
124- add_sign (line , severity )
111+ for bufname , severity in pairs (buffer_severity ) do
112+ local bufpath = utils .canonical_path (bufname )
113+ log .line (" diagnostics" , " bufpath '%s' severity %d" , bufpath , severity )
114+ if 0 < severity and severity < 5 then
115+ for line , node in pairs (nodes_by_line ) do
116+ local nodepath = utils .canonical_path (node .absolute_path )
117+ log .line (" diagnostics" , " %d checking nodepath '%s'" , line , nodepath )
118+ if M .show_on_dirs and vim .startswith (bufpath , nodepath ) then
119+ log .line (" diagnostics" , " matched fold node '%s'" , node .absolute_path )
120+ node .diag_status = severity
121+ add_sign (line , severity )
122+ elseif nodepath == bufpath then
123+ log .line (" diagnostics" , " matched file node '%s'" , node .absolute_path )
124+ node .diag_status = severity
125+ add_sign (line , severity )
126+ end
125127 end
126128 end
127129 end
128- end
129- log . profile_end ( ps , " diagnostics update " )
130+ log . profile_end ( ps , " diagnostics update " )
131+ end )
130132end
131133
132134local links = {
@@ -138,6 +140,7 @@ local links = {
138140
139141function M .setup (opts )
140142 M .enable = opts .diagnostics .enable
143+ M .debounce_delay = opts .diagnostics .debounce_delay
141144
142145 if M .enable then
143146 log .line (" diagnostics" , " setup" )
0 commit comments