Saghen / blink.cmp

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

`keymap.accept` prints my keymap when I press "enter" #47

Closed strash closed 1 day ago

strash commented 2 days ago

My blink config:

require("blink.cmp").setup({
    keymap = {
        show = "<C-f>",
        accept = "<CR>",
        select_prev = { "<Up>", "<C-p>" },
        select_next = { "<Down>", "<C-n>" },
        scroll_documentation_up = "<C-k>",
        scroll_documentation_down = "<C-j>",
    },
    highlight = {
        use_nvim_cmp_as_default = true,
    },
    nerd_font_variant = "mono",
    accept = {
        auto_brackets = {
            enabled = false
        }
    },
    trigger = {
        completion = {
            blocked_trigger_characters = { " ", "\n", "\t", "{", "}" },
        },
        signature_help = {
            enabled = true
        }
    },
    windows = {
        documentation = {
            max_width = 90,
            max_height = 47,
        },
    },
})

https://github.com/user-attachments/assets/1d4c5ebe-14e0-4896-86f9-f8fca8ca0b54

strash commented 2 days ago

Before the v0.2.1 update there was no such issue.

Saghen commented 2 days ago

This keymap code is tricky... please send the output of these two commands

:verbose map <cr>
:verbose imap <cr>
strash commented 2 days ago

:verbose map <cr>

s  <CR>        * <Lua 99: ~/.config/nvim/lua/map.lua:30>                                                                                                                                          
                 scroll down and align the cursor                                                                                                                                                 
        Last set from Lua (run Nvim with -V1 for more details)                                                                                                                                    
n  <CR>        * <Lua 80: ~/.config/nvim/lua/map.lua:30>                                                                                                                                          
                 scroll down and align the cursor                                                                                                                                                 
        Last set from Lua (run Nvim with -V1 for more details) 

:verbose imap <cr>

i  <CR>        *@<Lua 247: ~/.local/share/nvim/lazy/blink.cmp/lua/blink/cmp/keymap.lua:47>                                                                                                        
                 blink.cmp                                                                                                                                                                        
        Last set from Lua (run Nvim with -V1 for more details)                                                                                                                                    
i  <CR>        * <Lua 76: ~/.config/nvim/lua/map.lua:30>                                                                                                                                          
                 scroll down and align the cursor                                                                                                                                                 
        Last set from Lua (run Nvim with -V1 for more details) 
Saghen commented 2 days ago

Thanks! Could you send over your code for the two keymaps listed there?

strash commented 2 days ago

You mean this? ~/.config/nvim/lua/map.lua:30

    {
        mode = { "n", "i", "s" },
        key = "<CR>",
        cmd = function()
            if vim.snippet.active() then
                return map_util.wrap_in_cmd("lua vim.snippet.stop()")
            else
                return "<CR>"
            end
        end,
        opts = { desc = "scroll down and align the cursor", expr = true }
    },