From 541607cfbc7055e2d634df74a3a6e957bf48cc3e Mon Sep 17 00:00:00 2001 From: Jonas Widen Date: Mon, 17 Mar 2025 07:31:29 +0100 Subject: [PATCH] debug completion --- lua/gemini/completion.lua | 5 ++++- lua/gemini/init.lua | 26 +++++++------------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lua/gemini/completion.lua b/lua/gemini/completion.lua index 4026351..3870804 100644 --- a/lua/gemini/completion.lua +++ b/lua/gemini/completion.lua @@ -319,7 +319,10 @@ function M.setup() vim.api.nvim_create_autocmd("TextChangedI", { pattern = "*", callback = function() - M.trigger_completion() + -- Only trigger if enabled + if vim.b.gemini_completion_enabled then + M.trigger_completion() + end end }) diff --git a/lua/gemini/init.lua b/lua/gemini/init.lua index 9695f44..5f382ca 100644 --- a/lua/gemini/init.lua +++ b/lua/gemini/init.lua @@ -43,21 +43,10 @@ function M.setup(opts) config.setup(opts) pcall(vim.treesitter.language.require_language, "markdown") - -- Remove this duplicate keymap setup - -- require("gemini.completion").setup() - - -- Remove this duplicate keymap - -- vim.keymap.set('i', '', function() - -- require("gemini.completion").trigger_completion() - -- end, { desc = 'Trigger Gemini completion' }) - - -- Keep only this completion keymap - vim.keymap.set('i', '', function() - -- Force Gemini's omnifunc - vim.api.nvim_command('set omnifunc=v:lua.require\'gemini\'.complete') - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n', true) - end, { desc = 'Trigger Gemini completion' }) + -- Set up completion + completion.setup() + -- Set up commands vim.api.nvim_create_user_command("Gemini", function(opts) if opts.args == "" then vim.notify("Please provide a prompt for Gemini.", vim.log.levels.WARN) @@ -78,6 +67,7 @@ function M.setup(opts) desc = "Clear Gemini chat history" }) + -- Chat keymaps vim.keymap.set("n", "gc", function() M.prompt_query() end, { desc = "Chat with Gemini AI" }) @@ -92,11 +82,9 @@ function M.setup(opts) vim.notify("Chat history cleared", vim.log.levels.INFO) end, { desc = "Clear Gemini chat history" }) - -- Change the completion keymap to a more unique combination - vim.keymap.set('i', '', function() - -- Force Gemini's omnifunc - vim.api.nvim_command('set omnifunc=v:lua.require\'gemini\'.complete') - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n', true) + -- Completion keymaps + vim.keymap.set('i', 'gg', function() + completion.trigger_completion() end, { desc = 'Trigger Gemini completion' }) end