Adding spinny animation to lualine when LLM is running
This commit is contained in:
parent
44b6da6df3
commit
abfaa668f2
@ -1,4 +1,56 @@
|
||||
|
||||
local M = require("lualine.component"):extend()
|
||||
|
||||
M.processing = false
|
||||
M.spinner_index = 1
|
||||
|
||||
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)
|
||||
if request.match == "CodeCompanionRequestStarted" then
|
||||
self.processing = true
|
||||
elseif request.match == "CodeCompanionRequestFinished" then
|
||||
self.processing = false
|
||||
end
|
||||
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 require('lualine.components.location')()
|
||||
end
|
||||
end
|
||||
|
||||
require('lualine').setup {
|
||||
sections = {
|
||||
lualine_z = {M}
|
||||
},
|
||||
options = {
|
||||
theme = "catppuccin"
|
||||
-- theme = "citruszest"
|
||||
@ -6,3 +58,4 @@ require('lualine').setup {
|
||||
-- ... the rest of your lualine config
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user