Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keymap fallback doesn't handle script mappings #714

Open
2 tasks done
Kaiser-Yang opened this issue Dec 22, 2024 · 4 comments · May be fixed by #487
Open
2 tasks done

Keymap fallback doesn't handle script mappings #714

Kaiser-Yang opened this issue Dec 22, 2024 · 4 comments · May be fixed by #487
Labels
backlog Likely not getting to it anytime soon bug Something isn't working keymap

Comments

@Kaiser-Yang
Copy link
Contributor

Kaiser-Yang commented Dec 22, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • 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 Kaiser-Yang added the bug Something isn't working label Dec 22, 2024
@Kaiser-Yang
Copy link
Contributor Author

This is weird, this situation only happend on <cr>, auto-pairs also bind <space> with some other functionality, and I bind <space> to accept the first one in keymap of blink, and it works well.

@Kaiser-Yang
Copy link
Contributor Author

Switch to a new auto-pairs plug solve this problem: Kaiser-Yang/dotfiles@9998431

@tim3nd
Copy link
Contributor

tim3nd commented Dec 22, 2024

Seems same issue as #441 .
Current blink.cmp would identify keymap by desc , so after jiangmiao/auto-pairs reset keymap would cause problem in blink side. Should be fix after #487 merged.

@tim3nd
Copy link
Contributor

tim3nd commented Dec 22, 2024

Update keymap logic in jiangmiao/auto-pairs should also works, but seems the repo has been unmaintained.

Seems same issue as #441 . Current blink.cmp would identify keymap by desc , so after jiangmiao/auto-pairs reset keymap would cause problem in blink side. Should be fix after #487 merged.

@Saghen Saghen added the keymap label Dec 24, 2024
@Saghen Saghen changed the title Keymap with buffer type map not work expectedly when binding them with keymap in blink Keymap fallback doesn't handle script mappings Jan 3, 2025
@Saghen Saghen linked a pull request Jan 3, 2025 that will close this issue
@Saghen Saghen added the backlog Likely not getting to it anytime soon label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Likely not getting to it anytime soon bug Something isn't working keymap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants