local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Add mapping for (
vim.keymap.set('i', '(<Tab>', '()')
require("lazy").setup({
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
},
config = function()
local cmp = require'cmp'
local insert_mapping = cmp.mapping.preset.insert({})
cmp.setup({
mapping = insert_mapping,
confirmation = {
-- Confirm using '('
get_commit_characters = function(commit_characters) return {'('} end,
},
sources = cmp.config.sources( { { name = 'buffer' } } )
})
end,
},
})
Description
I have mapping for left bracket to insert right bracket. If i press '(' in completion and then i hit ESC to cancel right bracket insertion, cmp inserts characters on wrong places.
Steps to reproduce
open init.lua
write something
select completion with ctrl+n
hit '(' and ESC (fast)
Expected behavior
It should leave current selected completion.
Actual behavior
It inserts wrong text.
Additional context
Sometimes it leaves part of completion + '<Plug>(cmp.u.k.fallback_expr:)' in command line.
FAQ
Announcement
Minimal reproducible full config
Description
I have mapping for left bracket to insert right bracket. If i press '(' in completion and then i hit ESC to cancel right bracket insertion, cmp inserts characters on wrong places.
Steps to reproduce
Expected behavior
It should leave current selected completion.
Actual behavior
It inserts wrong text.
Additional context
Sometimes it leaves part of completion +
'<Plug>(cmp.u.k.fallback_expr:)'
in command line.