@@ -16,7 +16,7 @@ function M._build_input_win_config()
1616 col = 2 ,
1717 style = ' minimal' ,
1818 zindex = 41 ,
19- }
19+ } --[[ @as vim.api.keyset.win_config ]]
2020end
2121
2222function M .create_window (windows )
@@ -41,6 +41,7 @@ function M.close()
4141 if not M .mounted () then
4242 return
4343 end
44+ --- @cast state.windows { input_win : integer , input_buf : integer }
4445
4546 pcall (vim .api .nvim_win_close , state .windows .input_win , true )
4647 pcall (vim .api .nvim_buf_delete , state .windows .input_buf , { force = true })
@@ -51,6 +52,8 @@ function M.handle_submit()
5152 if not windows or not M .mounted (windows ) then
5253 return
5354 end
55+ --- @cast windows { input_buf : integer }
56+
5457 local input_content = table.concat (vim .api .nvim_buf_get_lines (windows .input_buf , 0 , - 1 , false ), ' \n ' )
5558 vim .api .nvim_buf_set_lines (windows .input_buf , 0 , - 1 , false , {})
5659 vim .api .nvim_exec_autocmds (' TextChanged' , {
@@ -177,6 +180,11 @@ function M.recover_input(windows)
177180end
178181
179182function M .focus_input ()
183+ if not M .mounted () then
184+ return
185+ end
186+ --- @cast state.windows { input_win : integer , input_buf : integer }
187+
180188 vim .api .nvim_set_current_win (state .windows .input_win )
181189
182190 local lines = vim .api .nvim_buf_get_lines (state .windows .input_buf , 0 , - 1 , false )
@@ -192,6 +200,7 @@ function M.set_content(text, windows)
192200 if not M .mounted (windows ) then
193201 return
194202 end
203+ --- @cast windows { input_win : integer , input_buf : integer }
195204
196205 local lines = type (text ) == ' table' and text or vim .split (tostring (text ), ' \n ' )
197206
@@ -212,6 +221,7 @@ function M.remove_mention(mention_name, windows)
212221 if not M .mounted (windows ) then
213222 return
214223 end
224+ --- @cast windows { input_buf : integer }
215225
216226 local lines = vim .api .nvim_buf_get_lines (windows .input_buf , 0 , - 1 , false )
217227 for i , line in ipairs (lines ) do
@@ -228,12 +238,12 @@ function M.remove_mention(mention_name, windows)
228238end
229239
230240function M .is_empty ()
231- local windows = state .windows
232- if not windows or not M .mounted () then
241+ if not M .mounted () then
233242 return true
234243 end
244+ --- @cast state.windows { input_buf : integer }
235245
236- local lines = vim .api .nvim_buf_get_lines (windows .input_buf , 0 , - 1 , false )
246+ local lines = vim .api .nvim_buf_get_lines (state . windows .input_buf , 0 , - 1 , false )
237247 return # lines == 0 or (# lines == 1 and lines [1 ] == ' ' )
238248end
239249
0 commit comments