Skip to content

Conversation

seblyng
Copy link
Contributor

@seblyng seblyng commented Sep 10, 2025

Problem:

In #2139 I outlined a bit about what issue I had, where expr mappings are being picked up before vim.on_key as opposed to regular mappings.

Solution:

Make it possible to return a string value to potentially opt out of the key being marked as typed.

With this I can for example do something like this:

["<CR>"] = {
    function(cmp)
        if not cmp.is_visible or require("blink.cmp.completion.list").get_selected_item() == nil then
            return
        end
        vim.schedule(function()
            cmp.accept()
        end)
        return vim.api.nvim_replace_termcodes("<ESC>a", true, false, true)
    end,
    "fallback",
}

This will make the callback invim.on_key not be invoked on <CR>

This allows for returning some string to potentially opt out of the
character literally being pressed, which means you can opt out to this
key being picked up by `vim.on_key` for example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant