forked from Robitx/gp.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspinner.lua
More file actions
56 lines (48 loc) · 1.03 KB
/
spinner.lua
File metadata and controls
56 lines (48 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local M = {}
M._spinner_frames = {
"01010010",
"01101111",
"01100010",
"01101001",
"01110100",
"01111000",
"00101111",
"01100111",
"01110000",
"00101110",
"01101110",
"01110110",
"01101001",
"01101101",
}
M._spinner_timer = nil
M._current_spinner_frame = 1
M._display_spinner = function(msg)
local spinner_msg = M._spinner_frames[M._current_spinner_frame] .. " " .. msg
vim.api.nvim_echo({ { spinner_msg, "Normal" } }, false, {})
M._current_spinner_frame = (M._current_spinner_frame % #M._spinner_frames) + 1
end
function M.start_spinner(msg)
-- Set or update the spinner message
M._msg = msg
-- Display the initial frame with the message
M._display_spinner(M._msg)
if not M._spinner_timer then
M._spinner_timer = (vim.uv or vim.loop).new_timer()
M._spinner_timer:start(
0,
100,
vim.schedule_wrap(function()
M._display_spinner(M._msg)
end)
)
end
end
function M.stop_spinner()
if M._spinner_timer then
M._spinner_timer:stop()
M._spinner_timer:close()
M._spinner_timer = nil
end
end
return M