zbirenbaum / copilot-cmp

Lua plugin to turn github copilot into a cmp source
MIT License
1.13k stars 41 forks source link

Error on Neovim startup: attempt to index field 'dynamic_capabilities' (a nil value) #84

Closed schoblaska closed 1 year ago

schoblaska commented 1 year ago

After this commit, I get this error when starting up Neovim:

Error detected while processing LspAttach Autocommands for "*":
Error executing lua callback: ...e/pack/packer/opt/copilot-cmp/lua/copilot_cmp/source.lua:29:
  attempt to index field 'dynamic_capabilities' (a nil value)
stack traceback:
        ...e/pack/packer/opt/copilot-cmp/lua/copilot_cmp/source.lua:29: in function
 <...e/pack/packer/opt/copilot-cmp/lua/copilot_cmp/source.lua:28>
        vim/shared.lua: in function 'tbl_filter'
        ...e/pack/packer/opt/copilot-cmp/lua/copilot_cmp/source.lua:28: in function 'is_available'
        ...ite/pack/packer/opt/copilot-cmp/lua/copilot_cmp/init.lua:30: in function '_on_insert_enter'
        ...ite/pack/packer/opt/copilot-cmp/lua/copilot_cmp/init.lua:43: in function
 <...ite/pack/packer/opt/copilot-cmp/lua/copilot_cmp/init.lua:42>
        [C]: in function 'nvim_exec_autocmds'
        ...w/Cellar/neovim/0.9.1/share/nvim/runtime/lua/vim/lsp.lua:1531: in function '_on_attach'
        ...w/Cellar/neovim/0.9.1/share/nvim/runtime/lua/vim/lsp.lua:1358: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

I'm using nvim_cmp and copilot.lua.

aw1875 commented 1 year ago

Not entirely sure what the commit was aiming for since I didn't take much time to look but changing line 29 in the source.lua file does the trick:

return client.id == self.client.id

instead of

return client.dynamic_capabilities.client_id == self.client.id
zbirenbaum commented 1 year ago

Not entirely sure what the commit was aiming for since I didn't take much time to look but changing line 29 in the source.lua file does the trick:

return client.id == self.client.id

instead of

return client.dynamic_capabilities.client_id == self.client.id

The breaking commit was a PR merge, I tested it and didn't get any errors, so not sure what happened. I made this edit which removes all references to dynamic capabilities so that should fix things.

schoblaska commented 1 year ago

@zbirenbaum Thanks for the quick fix! I really appreciate the work you put into these Copilot plugins. I use them constantly and the AI completions save me so much time.

chevcast commented 1 year ago

Yes, thank you for the quick fix. This copilot lazy setup saves so much manual config. Very much appreciated.