blink.cmp icon indicating copy to clipboard operation
blink.cmp copied to clipboard

Keymap with buffer type map not work expectedly when binding them with keymap in `blink`

Open Kaiser-Yang opened this issue 2 months ago • 4 comments

Make sure you have done the following

  • [X] I have updated to the latest version of blink.cmp
  • [X] I have read the README

Bug Description

I use jiangmiao/auto-pairs for auto close the braces and auto delete the close brace when deleting the open one, and auto indent after typing <cr>.

I use the below configuration for this plugin with lazy:

{
    'jiangmiao/auto-pairs',
    event = {'InsertEnter'},
    -- init = function() require'plugin_config/autopairs_config' end,
    -- lazy.nvim fails to load, we must initialize auto-pairs manually
    config = function()
        vim.cmd[[call AutoPairsTryInit()]]
    end,
},

This plugin will add some buffer type keybindings, for example the <cr> will be binded like this:

i  <CR>        &@<CR><SNR>76_AutoPairsReturn
	Last set from ~/.local/share/nvim/lazy/auto-pairs/plugin/auto-pairs.vim line 662

Then I use keymap in blink to bind <cr>:

keymap = {
    ['<cr>'] = { 'accept', 'fallback' },
}

After I press enter without selecting an item, I get this:

image

In order to make it work properly, now I just remove the buffer map <cr> when loading autopairs, and use a global mapping to map <cr> with auto indent functionality:

map.set({ 'i' }, '<cr>', '<c-g>u<cr><c-r>=AutoPairsReturn()<cr>', opts())

Relevant configuration

No response

neovim version

NVIM v0.10.1

blink.cmp version: branch, tag, or commit

v0.8.1

Kaiser-Yang avatar Dec 22 '24 06:12 Kaiser-Yang