Why do I have two completion menus in neovim and how to leave only one?

252 views Asked by At

As my primary IDE I use neovim with nvim-cmp set up for completion. It works great, but time to time another completion window appears (as i know, it is nvim's default keyword completion).

I have tried to disable completion plugins, to set variables, and to change config for nvim-cmp.

This is my nvim-cmp config:

set.completeopt = "menu,menuone,noselect"

cmp.setup({
    completion = {
        autocomplete = false,
    },

    opts = function(_, opts)
        -- opts parameter is the default options table
        -- the function is lazy loaded so cmp is able to be required
        local cmp = require("cmp")
        -- modify the sources part of the options table
        opts.sources = cmp.config.sources({
            { name = "nvim_lsp", priority = 1000 },
            { name = "luasnip", priority = 750 },
            { name = "buffer", priority = 500 },
            { name = "path", priority = 250 },
            { name = "vim-dadbod-completion", priority = 700 }, -- add new source
        })
        -- return the new table to be used
        return opts
    end,

    snippet = {
        expand = function(args)
            luasnip.lsp_expand(args.body)
        end,
    },
    mapping = cmp.mapping.preset.insert({
        ["<C-d>"] = cmp.mapping.scroll_docs(-4),
        ["<C-f>"] = cmp.mapping.scroll_docs(4),
        ["<C-Space>"] = cmp.mapping.complete(),
        ["<CR>"] = cmp.mapping.confirm({
            behavior = cmp.ConfirmBehavior.Replace,
            select = true,
        }),
    }),

    sources = {
        { name = "nvim_lsp" },
        { name = "luasnip" },
        { name = "buffer" },
        { name = "path" },
    },

    formatting = {
        format = function(entry, item)
            item.kind = lsp_symbols[item.kind]
            item.menu = ({
                buffer = "[Buffer]",
                nvim_lsp = "[LSP]",
                luasnip = "[Snippet]",
                neorg = "[Neorg]",
            })[entry.source.name]

            return item
        end,
    },
})

And this is how menus appear:

enter image description here

enter image description here

On both images unselectable menu appears at the bottom. I haven't found any solution. It seems like nobody has such issue. How do I get rid of it?

1

There are 1 answers

0
Aleksey Likhodievski On BEST ANSWER

I rewrote my config from scratch with only neccessary packages and now it works fine. I think the other menu was coming from CoC. Initialy I have been using CoC and forgot to remove it, once I switched to lsp.