summaryrefslogtreecommitdiffstatshomepage
path: root/nvim/.config/nvim/lua/tobyvin/utils/status.lua
blob: 173a005cd8a5f7c813e4caad3d548784a2dcb3e3 (plain)
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
local M = {}

M.signs = {
	started = { text = "ﳁ ", texthl = "diffChanged" },
	running = { text = "ﳁ ", texthl = "DiagnosticSignInfo" },
	failed = { text = " ", texthl = "DiagnosticSignError" },
	completed = { text = " ", texthl = "diffAdded" },
	spinner = { text = { "⣷", "⣯", "⣟", "⡿", "⢿", "⣻", "⣽", "⣾" }, texthl = "DiagnosticSignInfo" },
}

M.update_spinner = function(client_id, token)
	local notif_data = M.get_notif_data(client_id, token)

	if notif_data.spinner then
		local new_spinner = (notif_data.spinner + 1) % #M.status_signs.spinner.text
		notif_data.spinner = new_spinner

		notif_data.notification = vim.notify(nil, nil, {
			hide_from_history = true,
			icon = M.status_signs.spinner.text[new_spinner],
			replace = notif_data.notification,
		})

		vim.defer_fn(function()
			M.update_spinner(client_id, token)
		end, 100)
	end
end

return M