Saghen / blink.cmp

Performant, batteries-included completion plugin for Neovim
MIT License
631 stars 26 forks source link

fix: correctly handle non-blink keymaps with string rhs #78

Closed jose-elias-alvarez closed 10 hours ago

jose-elias-alvarez commented 16 hours ago

Given the following config:

require("blink.cmp").setup({
    keymap = {
        select_prev = { "<S-Tab>" },
    },
})

vim.keymap.set("i", "<S-Tab>", "<C-o>A")

Pressing <S-Tab> in insert mode when the Blink window is not visible creates an error:

E5108: Error executing lua: Vim:E15: Invalid expression: "^OA"

The issue is that nvim_eval is unconditionally called on mapping.rhs, so this PR fixes the logic to only evaluate the result of <expr> mappings.

I also fixed a bug in the if mapping conditions, which are a little different in nvim-cmp because these fields are converted into boolean values.

As you noted in a comment, handling fallback keymaps correctly in all cases is tricky, but for the moment, this should at least unblock a common case.

Saghen commented 10 hours ago

Thanks!