Skip to content

Instantly share code, notes, and snippets.

@lucax88x
Created March 29, 2024 16:27
Show Gist options
  • Save lucax88x/d7973e5cd984c67f13a9a9c480eca559 to your computer and use it in GitHub Desktop.
Save lucax88x/d7973e5cd984c67f13a9a9c480eca559 to your computer and use it in GitHub Desktop.
local M = require("lualine.component"):extend()
M.processing = false
M.spinner_index = 1
-- local spinner_symbols = { "▙ ", "▛ ", "▜ ", "▟ " }
local spinner_symbols = {
"⠋",
"⠙",
"⠹",
"⠸",
"⠼",
"⠴",
"⠦",
"⠧",
"⠇",
"⠏",
}
local spinner_symbols_len = 10
-- Initializer
function M:init(options)
M.super.init(self, options)
local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {})
vim.api.nvim_create_autocmd({ "User" }, {
pattern = "CodeCompanionRequest",
group = group,
callback = function(request)
self.processing = (request.data.status == "started")
end,
})
end
-- Function that runs every time statusline is updated
function M:update_status()
if self.processing then
self.spinner_index = (self.spinner_index % spinner_symbols_len) + 1
return spinner_symbols[self.spinner_index]
else
return nil
end
end
return M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment