diff --git a/lua/gemini/init.lua b/lua/gemini/init.lua index 492174f..5174446 100644 --- a/lua/gemini/init.lua +++ b/lua/gemini/init.lua @@ -12,7 +12,7 @@ local function get_current_buffer_content() return table.concat(lines, "\n") end -local function setup_treesitter_highlight(bufnr) +local function setup_chat_highlighting(bufnr) -- Enable treesitter for the buffer vim.api.nvim_buf_set_option(bufnr, 'syntax', '') local success = pcall(vim.treesitter.start, bufnr, "markdown") @@ -20,6 +20,14 @@ local function setup_treesitter_highlight(bufnr) -- Fallback to basic markdown syntax if treesitter fails vim.api.nvim_buf_set_option(bufnr, 'syntax', 'markdown') end + + -- Create syntax groups for user input and separators + vim.cmd([[ + highlight GeminiUser guifg=#88C0D0 gui=bold + highlight GeminiSeparator guifg=#616E88 gui=bold + syntax match GeminiUser /^User:.*$/ + syntax match GeminiSeparator /^━━━━━━━━━━━━━━━━━━━━━━━━━━$/ + ]]) end local function update_chat_window(new_content) @@ -87,8 +95,8 @@ local function update_chat_window(new_content) vim.api.nvim_win_set_option(chat_winnr, 'linebreak', true) vim.api.nvim_win_set_option(chat_winnr, 'breakindent', true) - -- Setup treesitter highlighting - setup_treesitter_highlight(chat_bufnr) + -- Setup custom highlighting + setup_chat_highlighting(chat_bufnr) -- Set window-local keymaps vim.keymap.set('n', 'q', function() @@ -109,6 +117,10 @@ local function update_chat_window(new_content) -- Make buffer modifiable vim.api.nvim_buf_set_option(chat_bufnr, 'modifiable', true) + -- Add separator before new content + local separator = "━━━━━━━━━━━━━━━━━━━━━━━━━━" + vim.api.nvim_buf_set_lines(chat_bufnr, -1, -1, false, {separator}) + -- Update content vim.api.nvim_buf_set_lines(chat_bufnr, -1, -1, false, vim.split(new_content, "\n")) @@ -129,7 +141,7 @@ end local function gemini_query(prompt, context) local response = api.get_response(prompt, context) if response then - local formatted_content = "\n\nUser: " .. prompt .. "\n\nAssistant: " .. response + local formatted_content = "\nUser: " .. prompt .. "\n\nAssistant: " .. response update_chat_window(formatted_content) else vim.notify("Failed to get a response from Gemini API", vim.log.levels.ERROR)