Added completion
This commit is contained in:
		| @@ -76,19 +76,28 @@ function M.trigger_completion() | ||||
|     local line = cursor[1] | ||||
|     local col = cursor[2] | ||||
|      | ||||
|     -- Get current buffer content for context | ||||
|     local lines = vim.api.nvim_buf_get_lines(0, math.max(0, line - 10), line, false) | ||||
|     local prefix = table.concat(lines, "\n") | ||||
|     -- Get entire buffer content | ||||
|     local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) | ||||
|      | ||||
|     -- Get current line up to cursor | ||||
|     local current_line = vim.api.nvim_get_current_line() | ||||
|     local before_cursor = string.sub(current_line, 1, col) | ||||
|     -- Split into before and after cursor | ||||
|     local before_lines = {} | ||||
|     local after_lines = {} | ||||
|      | ||||
|     -- Copy lines before cursor | ||||
|     for i = 1, line - 1 do | ||||
|         table.insert(before_lines, lines[i]) | ||||
|     end | ||||
|     -- Add current line up to cursor | ||||
|     local current_line = lines[line] | ||||
|     table.insert(before_lines, string.sub(current_line, 1, col)) | ||||
|      | ||||
|     -- Combine all lines before cursor | ||||
|     local prefix = table.concat(before_lines, "\n") | ||||
|      | ||||
|     -- Construct prompt for Gemini | ||||
|     local prompt = string.format( | ||||
|         "Complete this code. Only provide the completion, no explanation:\n%s\n%s", | ||||
|         prefix, | ||||
|         before_cursor | ||||
|         "Complete this code. Only provide the completion, no explanation:\n%s", | ||||
|         prefix | ||||
|     ) | ||||
|      | ||||
|     -- Get completion from Gemini | ||||
|   | ||||
		Reference in New Issue
	
	Block a user