diff --git a/lua/gemini/chat.lua b/lua/gemini/chat.lua index 73da27c..6ad3dbd 100644 --- a/lua/gemini/chat.lua +++ b/lua/gemini/chat.lua @@ -115,7 +115,20 @@ function M.update_content(content, is_new_chat) vim.api.nvim_buf_set_option(state.bufnr, 'modifiable', true) if is_new_chat then - vim.api.nvim_buf_set_lines(state.bufnr, 0, -1, false, vim.split(content, "\n")) + -- Don't clear existing content, append to it + local lines = vim.split(content, "\n") + if #state.conversation_history > 0 then + -- Add separator before new content + local separator = "━━━━━━━━━━━━━━━━━━━━━━━━━━" + table.insert(lines, 1, separator) + -- Get current buffer content + local current_lines = vim.api.nvim_buf_get_lines(state.bufnr, 0, -1, false) + -- Combine existing content with new content + for i = #current_lines, 1, -1 do + table.insert(lines, 1, current_lines[i]) + end + end + vim.api.nvim_buf_set_lines(state.bufnr, 0, -1, false, lines) else local separator = "━━━━━━━━━━━━━━━━━━━━━━━━━━" vim.api.nvim_buf_set_lines(state.bufnr, -1, -1, false, {separator})