zbirenbaum / copilot-cmp

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

Copilot is working but the completions do not appear in cmp menu #39

Closed OmkarKabadagi5823 closed 1 year ago

OmkarKabadagi5823 commented 1 year ago

I have installed copilot.lua and copilot-cmp. When I am trying to get suggestions from the copilot, I am getting suggestions in form of ghost texts instead of cmp-menu. I want them to be displayed in the cmp menu instead of ghost text

My configuration: user/plugins.lua

user/copilot.lua

user/cmp.lua

fecet commented 1 year ago

Same issue, copilot seems almost unplayable on my setup now

aenichols commented 1 year ago

Same issue for me. I can also provide my config if needed.

pwqbot commented 1 year ago

same issue, if I set auto_trigger = true in compilot.lua, completions do not appear in cmp menu, and will raise error `RPC[Error] code_name = InternalError, message = "Request getCompletions failed with message: the operation was aborted."

darksinge commented 1 year ago

I tried setting up copilot.lua and copilot-cmp for the first time today and have been struggling with this same issue. I get ghost text but can't get suggestions to show up with cmp. I've checked and double checked my configuration, but now I'm feeling like that's not the issue.

darksinge commented 1 year ago

Naturally, as soon as I comment on an issue I get it to work.

I nuked Packer's package root,

$ NVIM_DIR="$HOME/.local/share/nvim" # most likely install path
$ rm -rf "$NVIM_DIR/site/pack/packer"

followed by a reinstall and :PackerSync. Now it's working.


I did install github/copilot.vim first before realizing zbirenbaum/copilot.lua existed, so I wonder if there were left over artifacts that got cached from the github/copilot.vim install, causing some sort of collision. Total speculation, I have no idea.

ajaxbits commented 1 year ago

I am experiencing this same issue.

zbirenbaum commented 1 year ago

What version of node are you using? Node 16.x.x is the latest supported version by copilot and typically issues like this are from using too new a version.

I'm not sure why ghost text would work in that case though. If the node version checks out could you try loading copilot-cmp on InsertEnter and copilot.lua immediately? If that fixes it I'll patch a more permanent solution.

casret commented 1 year ago

What version of node are you using? Node 16.x.x is the latest supported version by copilot and typically issues like this are from using too new a version.

I'm not sure why ghost text would work in that case though. If the node version checks out could you try loading copilot-cmp on InsertEnter and copilot.lua immediately? If that fixes it I'll patch a more permanent solution.

Made these changes, and still getting ghost text without cmp suggestions.

D00mch commented 1 year ago

Same issue here. Node 16. OSX. Reinstalling the packer cache did not help.

I relaunched vim several times, and maybe two times out of thirty there were completions, as there should be.

ajaxbits commented 1 year ago

Fixed this by adding a formatting block to my cmp.setup() options like below:

local cmp = require'cmp'
cmp.setup({
    -- other config...

    formatting = {
        format = require("lspkind").cmp_format({
            mode = "symbol",
            symbol_map = { Copilot = '' }
        })
    }

    -- other config...
})

No idea why this works (I’m not super confident in my understanding of neovim’s lsp configuration details, nor of nvim-cmp), but the issue was solved as soon as I added these lines.

I’m managing neovim with nix, and you can check out the relevant config file here.

zbirenbaum commented 1 year ago

Did the above snippet work for others having this issue? Or is there still a problem with copilot.lua's ghost text taking precedent over copilot-cmp? I tracked down a solution if this is still an issue, but I haven't reproduced it so I'm not sure if it is.

D00mch commented 1 year ago

I tried everything and stil have 2 problems:

For now I just use auto_trigger true without cmp support.

ajaxbits commented 1 year ago

Selfishly, I'm interested in seeing the solution you found @zbirenbaum, since I still don't know why my solution works, and would love to learn more about possible root cause. But, personally, I'm all good now.

casret commented 1 year ago

Adding formatting did not help me. I already had it (albiet without the Copilot symbol map). I've re-read the thread and want to clarify my setup/problem since it's different than the OP. When I have auto_trigger: true I see the ghost text but no results in the cmp window (which does appear for other sources). When I have auto_trigger: false, I do see the the copilot cmp source. Is having both available supported?

primeapple commented 1 year ago

@casret , did you try enabling the ghost_text in nvim-cmp?

zbirenbaum commented 1 year ago

Selfishly, I'm interested in seeing the solution you found @zbirenbaum, since I still don't know why my solution works, and would love to learn more about possible root cause. But, personally, I'm all good now.

My idea for an edit actually shouldn't be necessary as long as you put enabled = false for both suggestion and panel config fields in copilot.lua setup. I recommend anyone here who does not have those to include it just in case since the default is enabled. I was just going to add some checks to make sure copilot isn't triggering something that is taking precedent, since both running at once causes issues due to rate limiting.

It is possible that if you have a filter for certain types of cmp completion kinds that copilot is getting filtered out as well. Internally, an item kind of 1 is text I believe, which some people may be filtering out.

zbirenbaum commented 1 year ago

I tried everything and stil have 2 problems:

  • I have to set :auto_trigger false to have completions;
  • completions occasionally stopped appearing, requiring me to restart neovim.

For now I just use auto_trigger true without cmp support.

What :auto_trigger are you referring to?

D00mch commented 1 year ago

What :auto_trigger are you referring to?

suggestion.auto_trigger in the config.

Sory, I used ":", because my config is in Fennel, and :auto_trigger is the same as "auto_trigger".

ajaxbits commented 1 year ago

Selfishly, I'm interested in seeing the solution you found @zbirenbaum, since I still don't know why my solution works, and would love to learn more about possible root cause. But, personally, I'm all good now.

My idea for an edit actually shouldn't be necessary as long as you put enabled = false for both suggestion and panel config fields in copilot.lua setup. I recommend anyone here who does not have those to include it just in case since the default is enabled. I was just going to add some checks to make sure copilot isn't triggering something that is taking precedent, since both running at once causes issues due to rate limiting.

It is possible that if you have a filter for certain types of cmp completion kinds that copilot is getting filtered out as well. Internally, an item kind of 1 is text I believe, which some people may be filtering out.

This totally worked for me. Setting the following fixed all my issues, even when I deleted my previous lspkind configuration:

require("copilot").setup({
    suggestion = {
      enabled = false;
    },
    panel = {
      enabled = false;
    },

    -- additional config...
})

I couldn't find anything in this repo or in the copilot.lua repo that gave me a clue that I should set these options as false for better compatibility with nvim-cmp.

This is probably since I'm not great at configuring nvim-cmp but do you think a note should be added to the readme to note these options, @zbirenbaum?

casret commented 1 year ago

I definitely like having the ghost text available also for the multi-line suggestions, but maybe I just need to tweak cmp to do what I want.

zbirenbaum commented 1 year ago

I definitely like having the ghost text available also for the multi-line suggestions, but maybe I just need to tweak cmp to do what I want.

This is likely why it is not working. Currently, copilot-cmp only supports cmp's ghost text, which is single line only. Enabling copilot.lua/copilot.vim style ghost text will break it because suggestions will be routed there instead of being populated in copilot-cmp.

zbirenbaum commented 1 year ago

Selfishly, I'm interested in seeing the solution you found @zbirenbaum, since I still don't know why my solution works, and would love to learn more about possible root cause. But, personally, I'm all good now.

My idea for an edit actually shouldn't be necessary as long as you put enabled = false for both suggestion and panel config fields in copilot.lua setup. I recommend anyone here who does not have those to include it just in case since the default is enabled. I was just going to add some checks to make sure copilot isn't triggering something that is taking precedent, since both running at once causes issues due to rate limiting. It is possible that if you have a filter for certain types of cmp completion kinds that copilot is getting filtered out as well. Internally, an item kind of 1 is text I believe, which some people may be filtering out.

This totally worked for me. Setting the following fixed all my issues, even when I deleted my previous lspkind configuration:

require("copilot").setup({
    suggestion = {
      enabled = false;
    },
    panel = {
      enabled = false;
    },

    -- additional config...
})

I couldn't find anything in this repo or in the copilot.lua repo that gave me a clue that I should set these options as false for better compatibility with nvim-cmp.

This is probably since I'm not great at configuring nvim-cmp but do you think a note should be added to the readme to note these options, @zbirenbaum?

I can definitely add a note to the readme, for me, unless I explicitly enable copilot.lua's suggestions copilot-cmp takes precedence, so I didn't think to add it before. I'm glad that solved the issue though, and I'll include a note.

At some point it would be nice to have synchronization between copilot-cmp and copilot.lua ghost text so multiline can be supported with copilot-cmp as @casret has expressed an interest in, but I am almost certain that would cause sizable issues with people using cmp supplied ghost text which works for all things, not just copilot suggestions.