@@ -57,21 +57,23 @@ local y_offset = 2 -- one border cell and one padding cell
57
57
58
58
--- @return OrgPromise<OrgDate | nil>
59
59
function Calendar :open ()
60
- local opts = {
61
- relative = ' editor' ,
62
- width = width ,
63
- height = height ,
64
- style = ' minimal' ,
65
- border = config .win_border ,
66
- row = vim .o .lines / 2 - (y_offset + height ) / 2 ,
67
- col = vim .o .columns / 2 - (x_offset + width ) / 2 ,
68
- title = self .title or ' Calendar' ,
69
- title_pos = ' center' ,
70
- }
60
+ local get_window_opts = function ()
61
+ return {
62
+ relative = ' editor' ,
63
+ width = width ,
64
+ height = height ,
65
+ style = ' minimal' ,
66
+ border = config .win_border ,
67
+ row = vim .o .lines / 2 - (y_offset + height ) / 2 ,
68
+ col = vim .o .columns / 2 - (x_offset + width ) / 2 ,
69
+ title = self .title or ' Calendar' ,
70
+ title_pos = ' center' ,
71
+ }
72
+ end
71
73
72
74
self .buf = vim .api .nvim_create_buf (false , true )
73
75
vim .api .nvim_buf_set_name (self .buf , ' orgcalendar' )
74
- self .win = vim .api .nvim_open_win (self .buf , true , opts )
76
+ self .win = vim .api .nvim_open_win (self .buf , true , get_window_opts () )
75
77
76
78
local calendar_augroup = vim .api .nvim_create_augroup (' org_calendar' , { clear = true })
77
79
vim .api .nvim_create_autocmd (' BufWipeout' , {
@@ -83,6 +85,16 @@ function Calendar:open()
83
85
once = true ,
84
86
})
85
87
88
+ vim .api .nvim_create_autocmd (' VimResized' , {
89
+ buffer = self .buf ,
90
+ group = calendar_augroup ,
91
+ callback = function ()
92
+ if self .win then
93
+ vim .api .nvim_win_set_config (self .win , get_window_opts ())
94
+ end
95
+ end ,
96
+ })
97
+
86
98
self :render ()
87
99
88
100
vim .api .nvim_set_option_value (' winhl' , ' Normal:Normal' , { win = self .win })
0 commit comments