11local state = require (' opencode.state' )
2+ local config = require (' opencode.config' )
23
34local Timer = require (' opencode.ui.timer' )
45local M = {}
56
67M ._animation = {
7- frames = { ' · ' , ' ․ ' , ' • ' , ' ∙ ' , ' ● ' , ' ⬤ ' , ' ● ' , ' ∙ ' , ' • ' , ' ․ ' } ,
8+ frames = nil ,
89 text = ' Thinking... ' ,
910 current_frame = 1 ,
1011 timer = nil ,
@@ -13,6 +14,17 @@ M._animation = {
1314 ns_id = vim .api .nvim_create_namespace (' opencode_loading_animation' ),
1415}
1516
17+ function M ._get_frames ()
18+ if M ._animation .frames then
19+ return M ._animation .frames
20+ end
21+ local ui_config = config .get (' ui' )
22+ if ui_config and ui_config .loading_animation and ui_config .loading_animation .frames then
23+ return ui_config .loading_animation .frames
24+ end
25+ return { ' ·' , ' ․' , ' •' , ' ∙' , ' ●' , ' ⬤' , ' ●' , ' ∙' , ' •' , ' ․' }
26+ end
27+
1628M .render = vim .schedule_wrap (function (windows )
1729 if not windows .footer_buf and not windows .output_buf or not vim .api .nvim_buf_is_valid (windows .output_buf ) then
1830 return false
@@ -28,7 +40,7 @@ M.render = vim.schedule_wrap(function(windows)
2840 return false
2941 end
3042
31- local loading_text = M ._animation .text .. M ._animation . frames [M ._animation .current_frame ]
43+ local loading_text = M ._animation .text .. M ._get_frames () [M ._animation .current_frame ]
3244
3345 M ._animation .extmark_id = vim .api .nvim_buf_set_extmark (windows .footer_buf , M ._animation .ns_id , 0 , 0 , {
3446 id = M ._animation .extmark_id or nil ,
@@ -41,7 +53,7 @@ M.render = vim.schedule_wrap(function(windows)
4153end )
4254
4355function M ._next_frame ()
44- return (M ._animation .current_frame % # M ._animation . frames ) + 1
56+ return (M ._animation .current_frame % # M ._get_frames () ) + 1
4557end
4658
4759function M ._start_animation_timer (windows )
0 commit comments