@@ -16,54 +16,6 @@ M.is_windows = function()
1616 return vim .fn .has (" win32" ) == 1
1717end
1818
19- local spinners = {} -- Store spinner timers by buffer
20- local icon_spinner = { " ⠋" , " ⠙" , " ⠹" , " ⠸" , " ⠼" , " ⠴" , " ⠦" , " ⠧" , " ⠇" , " ⠏" }
21-
22- M .start_spinner = function (bufnr , msg )
23- -- Stop any existing spinner for this buffer first to avoid timer leak
24- if spinners [bufnr ] then
25- M .stop_spinner (bufnr )
26- end
27-
28- local spinner_timer = vim .uv .new_timer ()
29- spinners [bufnr ] = { idx = 1 , timer = spinner_timer }
30-
31- spinners [bufnr ].timer :start (
32- 0 ,
33- 100 ,
34- vim .schedule_wrap (function ()
35- -- Check if the buffer is still valid before updating it
36- if not vim .api .nvim_buf_is_valid (bufnr ) then
37- M .stop_spinner (bufnr )
38- return
39- end
40-
41- if not spinners [bufnr ] then
42- return
43- end
44-
45- spinners [bufnr ].idx = (spinners [bufnr ].idx % # icon_spinner ) + 1
46- vim .api .nvim_buf_set_lines (bufnr , 0 , - 1 , false , {
47- icon_spinner [spinners [bufnr ].idx ] .. " " .. msg ,
48- " " ,
49- })
50- -- Move cursor to the last line only if we're currently in this buffer
51- if vim .api .nvim_get_current_buf () == bufnr then
52- local line_count = vim .api .nvim_buf_line_count (bufnr )
53- pcall (vim .api .nvim_win_set_cursor , 0 , { line_count , 0 })
54- end
55- end )
56- )
57- end
58-
59- M .stop_spinner = function (bufnr )
60- if spinners [bufnr ] then
61- spinners [bufnr ].timer :stop ()
62- spinners [bufnr ].timer :close ()
63- spinners [bufnr ] = nil
64- end
65- end
66-
6719M .fmt_relative_time = function (timestamp )
6820 -- Get current timestamp for relative time calculations
6921 local now = os.time ()
9547
9648-- Returns a list of { key, count } for non-zero diagnostic severities in the given buffer.
9749-- key is one of "error", "warning", "information", "hint".
98- local DIAGNOSTIC_KEYS = { " error" , " warning" , " information" , " hint" }
50+ local DIAGNOSTIC_SEVERITIES = {
51+ { key = " error" , severity = vim .diagnostic .severity .ERROR },
52+ { key = " warning" , severity = vim .diagnostic .severity .WARN },
53+ { key = " information" , severity = vim .diagnostic .severity .INFO },
54+ { key = " hint" , severity = vim .diagnostic .severity .HINT },
55+ }
56+
9957M .diagnostic_counts = function (bufnr )
10058 local results = {}
101- for i , key in ipairs (DIAGNOSTIC_KEYS ) do
102- local ki = vim .diagnostic .severity [i ]
103- local severity = vim .diagnostic .severity [ki ]
104- local count = vim .diagnostic .count (bufnr , { severity = severity })[severity ]
59+ for _ , entry in ipairs (DIAGNOSTIC_SEVERITIES ) do
60+ local s = entry .severity
61+ local count = vim .diagnostic .count (bufnr , { severity = s })[s ]
10562 if count and count > 0 then
106- table.insert (results , { key = key , count = count })
63+ table.insert (results , { key = entry . key , count = count })
10764 end
10865 end
10966 return results
0 commit comments