@@ -2,32 +2,32 @@ local M = {}
2
2
3
3
local ns = vim .api .nvim_create_namespace (' coc_diagnostic' )
4
4
5
- function M .on_diagnostic_change ()
5
+ function M .refresh ()
6
6
vim .diagnostic .reset (ns )
7
7
8
- local bufnr = vim .api .nvim_get_current_buf ()
9
- local ok , items = pcall (vim .api .nvim_buf_get_var , bufnr , ' coc_diagnostic_map' )
10
- if not ok or type (items ) ~= ' table' or vim .tbl_isempty (items ) then
11
- return
8
+ for _ , bufnr in ipairs (vim .api .nvim_list_bufs ()) do
9
+ if vim .api .nvim_buf_is_loaded (bufnr ) then
10
+ local ok , items = pcall (vim .api .nvim_buf_get_var , bufnr , ' coc_diagnostic_map' )
11
+ if ok and type (items ) == ' table' and vim .tbl_count (items ) >= 0 then
12
+ local diagnostics = {}
13
+ for _ , d in ipairs (items ) do
14
+ diagnostics [# diagnostics + 1 ] = {
15
+ bufnr = bufnr ,
16
+ lnum = d .location .range .start .line ,
17
+ end_lnum = d .location .range [' end' ].line ,
18
+ col = d .location .range .start .character ,
19
+ end_col = d .location .range [' end' ].character ,
20
+ severity = d .level ,
21
+ message = d .message ,
22
+ source = d .source ,
23
+ code = d .code ,
24
+ namespace = ns ,
25
+ }
26
+ end
27
+ vim .diagnostic .set (ns , bufnr , diagnostics )
28
+ end
29
+ end
12
30
end
13
-
14
- local diagnostics = {}
15
- for _ , d in ipairs (items ) do
16
- diagnostics [# diagnostics + 1 ] = {
17
- bufnr = 0 ,
18
- lnum = d .location .range .start .line ,
19
- end_lnum = d .location .range [' end' ].line ,
20
- col = d .location .range .start .character ,
21
- end_col = d .location .range [' end' ].character ,
22
- severity = d .level ,
23
- message = d .message ,
24
- source = d .source ,
25
- code = d .code ,
26
- namespace = ns ,
27
- }
28
- end
29
-
30
- vim .diagnostic .set (ns , bufnr , diagnostics )
31
31
end
32
32
33
33
return M
0 commit comments