hrsh7th / cmp-cmdline

nvim-cmp source for vim's cmdline
MIT License
567 stars 45 forks source link

C-n C-p not working #4

Closed ranebrown closed 3 years ago

ranebrown commented 3 years ago

Using the below mappings and cmdline setup it is not possible to select entries that appear using C-n or C-p. I'm guessing this is because of the c_CTRL-N and c_CTRL-P mappings. Also using this which might be relevant set wildmode=longest:full,full. Any suggestions on a workaround?

   mapping = {
        ["<C-y>"] = cmp.mapping.confirm(),
        ["<C-n>"] = function()
            if cmp.visible() then
                cmp.select_next_item()
            else
                cmp.complete()
            end
        end,
        ["<C-p>"] = function()
            if cmp.visible() then
                cmp.select_prev_item()
            else
                cmp.complete()
            end
        end,
        ["<C-d>"] = cmp.mapping.scroll_docs(-4),
        ["<C-f>"] = cmp.mapping.scroll_docs(4),
        ["<C-e>"] = cmp.mapping.close(),
    },
hrsh7th commented 3 years ago

You should specify the mapping mode. Please read the nvim-cmp's README.md

        ["<C-n>"] = cmp.mapping(function()
            if cmp.visible() then
                cmp.select_next_item()
            else
                cmp.complete()
            end
        end, { 'i', 'c' }),
ranebrown commented 3 years ago

Thanks, didn't catch those updates.