5656--- @param context_key string
5757--- @return boolean
5858function M .is_context_enabled (context_key )
59- local is_enabled = vim .tbl_get (config , ' context' , context_key , ' enabled' )
59+ local is_enabled = vim .tbl_get (config --[[ @as table ]] , ' context' , context_key , ' enabled' )
6060 local is_state_enabled = vim .tbl_get (state , ' current_context_config' , context_key , ' enabled' )
6161
6262 if is_state_enabled ~= nil then
@@ -76,7 +76,7 @@ function M.get_diagnostics(buf)
7676 return {}
7777 end
7878
79- local global_conf = vim .tbl_get (config , ' context' , ' diagnostics' ) or {}
79+ local global_conf = vim .tbl_get (config --[[ @as table ]] , ' context' , ' diagnostics' ) or {}
8080 local diagnostic_conf = vim .tbl_deep_extend (' force' , global_conf , current_conf ) or {}
8181
8282 local severity_levels = {}
@@ -264,7 +264,8 @@ function M.get_current_cursor_data(buf, win)
264264 end
265265
266266 local cursor_pos = vim .fn .getcurpos (win )
267- local cursor_content = vim .trim (vim .api .nvim_buf_get_lines (buf , cursor_pos [2 ] - 1 , cursor_pos [2 ], false )[1 ] or ' ' )
267+ local start_line = (cursor_pos [2 ] - 1 ) --[[ @as integer]]
268+ local cursor_content = vim .trim (vim .api .nvim_buf_get_lines (buf , start_line , cursor_pos [2 ], false )[1 ] or ' ' )
268269 return { line = cursor_pos [2 ], column = cursor_pos [3 ], line_content = cursor_content }
269270end
270271
384385function M .format_message (prompt , opts )
385386 opts = opts or config .context
386387 local context = M .delta_context (opts )
387- context .prompt = prompt
388388
389389 local parts = { { type = ' text' , text = prompt } }
390390
430430
431431--- Extracts context from an OpencodeMessage (with parts)
432432--- @param message { parts : OpencodeMessagePart[] }
433- --- @return { prompt : string , selected_text : string | nil , current_file : string | nil , mentioned_files : string[] | nil }
433+ --- @return { prompt : string | nil , selected_text : string | nil , current_file : string | nil , mentioned_files : string[] | nil }
434434function M .extract_from_opencode_message (message )
435435 local ctx = { prompt = nil , selected_text = nil , current_file = nil }
436436
0 commit comments