zbirenbaum / copilot-cmp

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

Error Attempt to call method 'complete' (a nil value) #54

Closed EngoDev closed 1 year ago

EngoDev commented 1 year ago

Hello :) I recently updated my plugins and after I did I was met with the following error image

I did some investigating in the code and found the bug and I have a fix for it: In source.lua line 57 opts.method gives the value getCompletionCycling and not getCompletionsCycling (The difference is the singular Completion vs Completions). Then when it's passed down to completion_functions.init in line 88, completion_functions don't have the method getCompletionCycling so everything returns back nil which causes the mentioned error above when trying to call the complete function from source

I would love to create a pull request for the fix myself but if that's not possible I can provide snippets for the fix :)

Thank you for making an amazing plugin, I use it everyday ⭐ 😁

dotennin commented 1 year ago

I got the same error yesterday . Hope this can be fixed ASAP.

zbirenbaum commented 1 year ago

I checked in source.lua and this is what I found: local completion_fn = opts.method or "getCompletionsCycling"

opts.method is the field corresponding to your configuration options. This is a config issue.

Since there's no longer multiple completion_fn options implemented due to changes in copilot itself, I went ahead and pushed a change which will make it impossible to override the value.

I kind-of want to keep it the way it is so people can write their own completion methods if they want, but I think it is more trouble than it is work atm.