hrsh7th / nvim-cmp

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

Error executing vim.schedule lua callback: vim/shared.lua:0: after the second argument: expected table, got nil #1397

Open tzachar opened 1 year ago

tzachar commented 1 year ago

FAQ

Announcement

Minimal reproducible full config

Description

The following exception is randomly thrown:

Error executing vim.schedule lua callback: vim/shared.lua:0: after the second argument: expected table, got nil                                                               
stack traceback:                                                                                                                                                              
        [C]: in function 'error'                                                                                                                                              
        vim/shared.lua: in function 'validate'                                                                                                                                
        vim/shared.lua: in function 'tbl_deep_extend'                                                                                                                         
        ...cal/share/nvim/lazy/cmp-cmdline/lua/cmp_cmdline/init.lua:165: in function 'complete'                                                                               
        ...achar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:325: in function 'complete'                                                                               
        ...tzachar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:279: in function 'callback'                                                                               
        ...achar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:365: in function ''                                                                                       
        vim/_editor.lua: in function <vim/_editor.lua:0>                 

I dont have a way to reliably reproduce it. This has been happening to other people, see for example tzachar/cmp-fuzzy-buffer#6

Steps to reproduce

happens from time to time. no reliable way to reproduce

Expected behavior

no error....

Actual behavior

errorr thrown

Additional context

No response

tzachar commented 1 year ago

Still getting this:

Error executing vim.schedule lua callback: vim/shared.lua:0: after the second argument: expected table, got nil                                                               
stack traceback:                                                                                                                                                              
        [C]: in function 'error'                                                                                                                                              
        vim/shared.lua: in function 'validate'                                                                                                                                
        vim/shared.lua: in function 'tbl_deep_extend'                                                                                                                         
        ...cal/share/nvim/lazy/cmp-cmdline/lua/cmp_cmdline/init.lua:165: in function 'complete'                                                                               
        ...achar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:325: in function 'complete'                                                                               
        ...tzachar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:279: in function 'callback'                                                                               
        ...achar/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:365: in function ''                                                                                       
        vim/_editor.lua: in function <vim/_editor.lua:0>                                                     
tzachar commented 1 year ago

@hrsh7th Still getting this...

tzachar commented 1 year ago

@hrsh7th Alas, this is still happening to me :(

jm96441n commented 1 year ago

I'm getting this as well, it happens sporadically on save:

Error executing vim.schedule lua callback: vim/shared.lua:0: after the second argument: expected table, got nil
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'tbl_deep_extend'
        ...e/pack/packer/start/cmp-cmdline/lua/cmp_cmdline/init.lua:165: in function 'complete'
        .../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:325: in function 'complete'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:279: in function 'callback'
        .../nvim/site/pack/packer/start/nvim-cmp/lua/cmp/source.lua:365: in function ''
lpxxn commented 1 year ago
E5108: Error executing lua vim/shared.lua:0: t: expected table, got boolean
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'tbl_contains'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:168: in function 'autoindent'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/init.lua:304: in function <...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/init.lua:299>
        ...te/pack/packer/start/nvim-cmp/lua/cmp/utils/feedkeys.lua:47: in function <...te/pack/packer/start/nvim-cmp/lua/cmp/utils/feedkeys.lua:45>
wllenyj commented 1 year ago

When you configure cmp, check whether you have used the wrong configuration.

cmp.setup({
    completion = {
        completeopt = 'menu,menuone,noinsert',
        autocomplete = true,
    },
...

Here, autocomplete is configured as bool type. But according to the error message, it should be of type table.

if vim.tbl_contains(config.get().completion.autocomplete or {}, trigger_event) then
tzachar commented 1 year ago

Not related, this is my config:

autocomplete = { types.cmp.TriggerEvent.InsertEnter, types.cmp.TriggerEvent.TextChanged },
jaesoekjjang commented 2 months ago

For me, the error only showed while editing ts, tsx filetypes. And I could solve the problem by removing this line.

["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics),
arjablc commented 2 months ago

My fix I had a typo where I forgot parenthesis

local capabilities = require('cmp_nvim_lsp').default_capabilities()

and passed in capabilites when calling the

lspconfig.[lsp_server].setup({
  capabilities = capabilities
})

after adding the parenthesis I no longer get the error. this error occurs when passing something to the setup function that is not a table. so i think recheck that