nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

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

Open tzachar opened this issue 3 years ago • 9 comments

FAQ

  • [X] I have checked the FAQ and it didn't resolve my problem.

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 avatar Jan 09 '23 10:01 tzachar

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 avatar Jan 17 '23 09:01 tzachar

@hrsh7th Still getting this...

tzachar avatar Feb 16 '23 15:02 tzachar

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

tzachar avatar Feb 26 '23 07:02 tzachar

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 ''

jm96441n avatar Mar 09 '23 00:03 jm96441n

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>

lpxxn avatar May 10 '23 03:05 lpxxn

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

wllenyj avatar Jun 09 '23 16:06 wllenyj

Not related, this is my config:

autocomplete = { types.cmp.TriggerEvent.InsertEnter, types.cmp.TriggerEvent.TextChanged },

tzachar avatar Jun 11 '23 06:06 tzachar

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),

jaesoekjjang avatar Aug 03 '24 16:08 jaesoekjjang

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

arjablc avatar Aug 26 '24 10:08 arjablc