hrsh7th / nvim-cmp

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

Error executing lua ..../.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:143: bad argument #1 to 'pairs' (table expect ed, got boolean) #1724

Closed Meakoala closed 12 months ago

Meakoala commented 12 months ago

FAQ

Announcement

Minimal reproducible full config

-- nvimcmp.lua
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable",
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    "hrsh7th/nvim-cmp",
    event = { "InsertEnter" },
    enabled = true,
    dependencies = {
        "L3MON4D3/LuaSnip",
        "saadparwaiz1/cmp_luasnip",
        "rafamadriz/friendly-snippets",
        "hrsh7th/cmp-nvim-lsp",
        "hrsh7th/cmp-nvim-lua",
        "hrsh7th/cmp-buffer",
        "hrsh7th/cmp-path",
        "hrsh7th/cmp-cmdline",
        "hrsh7th/cmp-emoji",
    },
config = function()
    local luasnip = require "luasnip"
    require('luasnip.loaders.from_vscode').lazy_load()
    luasnip.config.setup {}
    local cmp = require "cmp"
    local select = { behavior = cmp.SelectBehavior.Select }
    local mapping = {
        ["<C-n>"] = cmp.select_next_item(select),
        ["<C-p>"] = cmp.select_prev_item(select),
        ["<C-d>"] = cmp.mapping.scroll_docs(-4),
        ["<C-f>"] = cmp.mapping.scroll_docs(4),
        ["<C-y>"] = cmp.mapping.confirm({ select = false }),
        ["<C-Space>"] = cmp.mapping.complete(),
    }

    cmp.setup({
        completion = {
            completeopt = "menu,menuone,noinsert,noselect",
        },
        snippet = {
            expand = function(args)
                luasnip.lsp_expand(args.body)
            end,
        },
        mapping = mapping,
        sources = {
            { name = "nvim_lsp" },
            { name = "luasnip" },
            { name = "buffer" },
            { name = "path" },
            { name = "emoji" },
        },
    })
end
})

Description

I currently in middle of nuke and reconfig my neovim migrate from packer to lazy. then setup nvim-cmp first time is no error as expected, but after config further and restart go in command line or insert mode I got this error.

E5108: Error executing lua /home/kia/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:143: bad argument #1 to 'pairs' (table expect
ed, got boolean)                                                                                                                   
stack traceback:                                                                                                                   
        [C]: in function 'pairs'                                                                                                   
        /home/kia/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:143: in function 'prepare'                                      
        /home/kia/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:328: in function </home/kia/.local/share/nvim/lazy/nvim-cmp/lua/
cmp/init.lua:324>                                                                                                                  
        ...ocal/share/nvim/lazy/nvim-cmp/lua/cmp/utils/feedkeys.lua:47: in function <...ocal/share/nvim/lazy/nvim-cmp/lua/cmp/utils
/feedkeys.lua:45>

Steps to reproduce

  1. make minimal config form my plugin module nvimcmp.lua
  2. open with nvim -u nvimcmp.lua
  3. enter insert or command mode
  4. got error

Expected behavior

no error. running normal as 2 hour ago.

Actual behavior

E5108: Error executing lua /home/kia/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:143: bad argument #1 to 'pairs' (table expect
ed, got boolean)                                                                                                                   
stack traceback:                                                                                                                   
        [C]: in function 'pairs'                                                                                                   
        /home/kia/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:143: in function 'prepare'                                      
        /home/kia/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:328: in function </home/kia/.local/share/nvim/lazy/nvim-cmp/lua/
cmp/init.lua:324>                                                                                                                  
        ...ocal/share/nvim/lazy/nvim-cmp/lua/cmp/utils/feedkeys.lua:47: in function <...ocal/share/nvim/lazy/nvim-cmp/lua/cmp/utils
/feedkeys.lua:45>

Additional context

NVIM v0.10.0-dev-1295+g1f864139b

I have try nuke my config and it still happen.

Meakoala commented 12 months ago

I have Nuke my neovim and it fix now. for what make it happened I'm not sure but I think it maybe name collusion or something like that I can't find what collide with so I just wipe it all.