zbirenbaum / copilot-cmp

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

Copilot crashing the language server #18

Closed svilupp closed 1 year ago

svilupp commented 1 year ago

First of all, thank you for the amazing plugin!

Is Copilot meant to co-exist with other language servers in the same buffer? I suspect that it clashes with a language server.

Expected behaviour: When I open a julia language file, Copilot and Julia LanguageServer would be both loaded and contribute with suggestions to cmp.

Current behaviour: Julia LanguageServer crashes within minutes because CMP(?) tries to call a method "getCompletionsCycling" from Julia LS, which is undefined, so it crashes. I cannot find any option to change to prevent that and it's not listed in any server capabilities or so. I suspect it has to do with the copilot-cmp internals.

Stacktrace: "ERROR: " "LoadError: " "Unknown method getCompletionsCycling.\nStacktrace:\n [1] " (the rest is just JSON rpc calls and deeper in Julia stack)

System:

zbirenbaum commented 1 year ago

Yes it is meant to coexist. I haven't encountered any other language servers that crash because of it, but maybe julials doesn't have the most robust error handling. I can try converting any buf calls to rpc ones later so no other ls will be affected.

svilupp commented 1 year ago

I'm not sure it's caused by Julia LS, because it seems to co-exist fine in VSCode.

Would you have a hunch what buff calls could be causing it / how I can try to replicate to confirm?

I’ve tried to read through the lua code base and it seemed like you always check for copilot agent before you attach any capabilities, etc. But based on your comment, is it because of this line? https://github.com/zbirenbaum/copilot-cmp/blob/e93c7c8eab2e98c0fe34619cfb7487d13fb756a4/lua/copilot_cmp/completion_functions.lua#L30

zbirenbaum commented 1 year ago

I'm not sure it's caused by Julia LS, because it seems to co-exist fine in VSCode.

Would you have a hunch what buff calls could be causing it / how I can try to replicate to confirm?

I’ve tried to read through the lua code base and it seemed like you always check for copilot agent before you attach any capabilities, etc. But based on your comment, is it because of this line?

https://github.com/zbirenbaum/copilot-cmp/blob/e93c7c8eab2e98c0fe34619cfb7487d13fb756a4/lua/copilot_cmp/completion_functions.lua#L30

Yeah thats the one, buf_request sends it to all LSPs attached to the buffer. I just need to change it to use the rpc api which is more low level and accessed from the client object directly.

Alternatively, if you would like to PR the change and become a contributor, you are more than welcome to, and I am happy to help out if you have any questions. I believe I make use of the rpc api for getPanelCompletions in that same file if an example would help.

svilupp commented 1 year ago

I've never written anything in lua - I just read it as plain English, so it might be a bit too ambitious.

I'll try to draft something by EoD.

zbirenbaum commented 1 year ago

I've never written anything in lua - I just read it as plain English, so it might be a bit too ambitious.

I'll try to draft something by EoD.

If it gets frustrating or is a bit too much to take on don't hesitate to let me know. It's a little late right now, but it shouldn't take me longer than a few minutes to implement tomorrow. I use a lot of pretty low level api calls, and the function I referenced as an example, while pretty well documented, is not a simple piece of code at all, and the one you are looking at editing isn't trivial either. The neovim api can be a bit difficult to jump into starting out.

I just brought it up since you identified the issue on your own as well as the location, and that's typically half the battle for stuff like this.