diff --git a/lua/gemini/completion.lua b/lua/gemini/completion.lua index c1c3d40..1405ffd 100644 --- a/lua/gemini/completion.lua +++ b/lua/gemini/completion.lua @@ -167,8 +167,8 @@ function M.trigger_completion() -- Construct context from buffer local context = {} - -- Add up to 5 previous lines for context (reduced from 10) - local start_line = math.max(1, line - 5) + -- Add up to 10 previous lines for context + local start_line = math.max(1, line - 10) for i = start_line, line - 1 do table.insert(context, lines[i]) end @@ -176,12 +176,18 @@ function M.trigger_completion() -- Add current line table.insert(context, current_line) + -- Add up to 10 lines after current line + local end_line = math.min(#lines, line + 10) + for i = line + 1, end_line do + table.insert(context, lines[i]) + end + -- Combine all lines local full_context = table.concat(context, "\n") -- Construct prompt for Gemini local prompt = string.format( - "Complete this code. Return ONLY the completion that would naturally follow, no explanation:\n%s", + "Complete this code. Consider the context (10 lines before and after). Return ONLY the completion that would naturally follow at the cursor position, no explanation:\n%s", full_context )