This commit is contained in:
Jonas Widen 2025-03-16 21:06:51 +01:00
parent 1fefe53ff3
commit 330074f016

View File

@ -24,10 +24,8 @@ function M.query(prompt, context)
chat.set_context(context) chat.set_context(context)
chat.create_window() chat.create_window()
-- Don't add the thinking message to conversation history
local initial_content = "User: " .. prompt .. "\n\nAssistant: Thinking..." local initial_content = "User: " .. prompt .. "\n\nAssistant: Thinking..."
chat.update_content(initial_content, true, true) -- Add new parameter to indicate temporary content chat.update_content(initial_content, true, true)
vim.cmd('redraw')
api.get_response(prompt, context, function(response, error) api.get_response(prompt, context, function(response, error)
if error then if error then
@ -41,13 +39,9 @@ function M.query(prompt, context)
end end
function M.setup(opts) function M.setup(opts)
-- Configure the plugin
config.setup(opts) config.setup(opts)
-- Ensure markdown parser is installed
pcall(vim.treesitter.language.require_language, "markdown") pcall(vim.treesitter.language.require_language, "markdown")
-- Create commands
vim.api.nvim_create_user_command("Gemini", function(opts) vim.api.nvim_create_user_command("Gemini", function(opts)
if opts.args == "" then if opts.args == "" then
vim.notify("Please provide a prompt for Gemini.", vim.log.levels.WARN) vim.notify("Please provide a prompt for Gemini.", vim.log.levels.WARN)
@ -68,7 +62,6 @@ function M.setup(opts)
desc = "Clear Gemini chat history" desc = "Clear Gemini chat history"
}) })
-- Set up default keymaps
vim.keymap.set("n", "<leader>gc", function() vim.keymap.set("n", "<leader>gc", function()
M.prompt_query() M.prompt_query()
end, { desc = "Chat with Gemini AI" }) end, { desc = "Chat with Gemini AI" })