Skip to content

Commit

Permalink
Make insert complete mapping accept completion if pum is visible
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Slusny <[email protected]>
  • Loading branch information
deathbeam committed Nov 20, 2024
1 parent 0d76668 commit 1062c99
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/CopilotChat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<C-y>' 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
Expand Down

0 comments on commit 1062c99

Please sign in to comment.