From 1062c99b272aeb2c0ecf0c963a8a4c6deb0abdda Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Wed, 20 Nov 2024 13:48:39 +0100 Subject: [PATCH] Make insert complete mapping accept completion if pum is visible Signed-off-by: Tomas Slusny --- lua/CopilotChat/init.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index f1eb8e26..8427d293 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -317,8 +317,14 @@ local function map_key(key, bufnr, fn) vim.keymap.set('i', key.insert, function() -- If in insert mode and menu visible, use original key if vim.fn.pumvisible() == 1 then - local keys = vim.api.nvim_replace_termcodes(key.insert, true, false, true) - vim.api.nvim_feedkeys(keys, 'n', false) + local used_key = key.insert == M.config.mappings.complete.insert and '' or key.insert + if used_key then + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes(used_key, true, false, true), + 'n', + false + ) + end else fn() end