hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.9k stars 394 forks source link

<C-n> not using nvim-cmp's menu but some other menu whenever i go to the first entry #1717

Closed choucavalier closed 1 year ago

choucavalier commented 1 year ago

FAQ

Announcement

Minimal reproducible full config

    {
        "hrsh7th/nvim-cmp",
        dependencies = {
            "hrsh7th/cmp-nvim-lsp",
            'hrsh7th/cmp-buffer',
            'hrsh7th/cmp-path',
            'hrsh7th/cmp-cmdline',
            "L3MON4D3/LuaSnip",
            "saadparwaiz1/cmp_luasnip",
        },
        config = function()
            local cmp = require("cmp")
            cmp.setup({
                snippet = {
                    expand = function(args) require("luasnip").lsp_expand(args.body) end,
                },
                mappings = cmp.mapping.preset.insert({
                    ["<CR>"] = cmp.mapping.confirm({ select = true }),
                    ["<Tab>"] = cmp.mapping(function(fallback)
                        if cmp.visible() then
                            cmp.select_next_item()
                        else
                            fallback()
                        end
                    end, { "i", "s" }),
                    ["<S-Tab>"] = cmp.mapping(function(fallback)
                        if cmp.visible() then
                            cmp.select_prev_item()
                        else
                            fallback()
                        end
                    end, { "i", "s" }),
                }),
                sources = cmp.config.sources({
                    { name = "nvim_lsp:pyright" },
                    { name = "cmdline" },
                    { name = "path" },
                    { name = "buffer" },
                    { name = "luasnip" },
                }),
            })
        end,
    },

Description

asciicast

Pressing <C-n> makes the nvim-cmp menu disappear and switches back to some other default menu. I don't know what's happening

Steps to reproduce

Use my nvim-cmp config

Expected behavior

I would expect the nvim-cmp to be used instead, even though I switch to the next item in the list

Actual behavior

Some other menu appears, which seems to be the default menu.

Additional context

No response

choucavalier commented 1 year ago

After some research it seems to be the same issue as in https://github.com/hrsh7th/nvim-cmp/issues/916

I've set the following mappings and it does not solve the problem

    {
        "hrsh7th/nvim-cmp",
        dependencies = {
            "hrsh7th/cmp-nvim-lsp",
            'hrsh7th/cmp-buffer',
            'hrsh7th/cmp-path',
            'hrsh7th/cmp-cmdline',
            "L3MON4D3/LuaSnip",
            "saadparwaiz1/cmp_luasnip",
        },
        config = function()
            local cmp = require("cmp")
            cmp.setup({
                snippet = {
                    expand = function(args) require("luasnip").lsp_expand(args.body) end,
                },
                mappings = cmp.mapping.preset.insert({
                    ["<CR>"] = cmp.mapping.confirm({ select = true }),
                    ["<C-n>"] = cmp.mapping.select_next_item(),
                    ["<C-p>"] = cmp.mapping.select_prev_item(),
                }),
                sources = cmp.config.sources({
                    { name = "nvim_lsp" },
                    { name = "cmdline" },
                    { name = "path" },
                    { name = "buffer" },
                    { name = "luasnip" },
                }),
            })
        end,
    },

:set paste? shows that I have it correctly set to nopaste

choucavalier commented 1 year ago

goddamn it, this was due to me writing mappings instead of mapping in the setup... closing