zbirenbaum / copilot-cmp

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

`copilot` is an unknown source name #13

Closed MikiVanousek closed 2 years ago

MikiVanousek commented 2 years ago

I installed according to the instructions. (~/.config/githubcopilot exists)

{ 'zbirenbaum/copilot.lua',
    config = function()
      require("copilot").setup()
    end, },
  { 'zbirenbaum/copilot-cmp',
    after = { "copilot.lua", "nvim-cmp" },
  },

...

lvim.builtin.cmp.sources = {
  { name = "copilot", group_index = 2 },
  { name = "nvim_lsp", group_index = 2 },
  { name = "path", group_index = 2 },
  { name = "luasnip", group_index = 2 },
}

Both plugins seem to be installed, but :CmpInfo produces

# ready source names                                                                                                                                                                                                                  
- path
- luasnip
- nvim_lsp:sumneko_lua

# unused source names
- buffer

# unknown source names
- copilot

It would be nice, if the two plugins copilot.lua and copilot-cmp would list steps to verify installation, as I am not even sure where to file this issue.

crisidev commented 2 years ago

I have the same issue..

zbirenbaum commented 2 years ago

This should be fixed as of today. If it's still reproducible after a PackerSync please reopen.

It would be nice, if the two plugins copilot.lua and copilot-cmp would list steps to verify installation, as I am not even sure where to file this issue.

As a general rule, if LspInfo shows copilot up and running, copilot.lua is working fine. There are rare exceptions to that rule, which would likely show up in your lsp logfile.

If CmpStatus is giving unexpected information, then its likely a copilot_cmp issue.

What seems to be the cause of this was a rare exception to the first rule, wherein microsoft made some changes to the backend that caused some difficult to diagnose problems while I've been quite busy with graduation stuff. Thankfully one of the users in copilot.lua came out with a PR after discovering a parameter that is now required. Very sorry for any frustration this may have caused.

MikiVanousek commented 2 years ago

Very sorry for any frustration this may have caused.

No worries mate. : ) Unfortunately, with the minimal configuration I specified above, the issue persists. LspInfo does not show copilot. This means it is a copilot.lua issue. Should I refile there?

zbirenbaum commented 2 years ago

Very sorry for any frustration this may have caused.

No worries mate. : ) Unfortunately, with the minimal configuration I specified above, the issue persists. LspInfo does not show copilot. This means it is a copilot.lua issue. Should I refile there?

Yeah keep this closed and open a new post there. Before that though, try loading copilot.lua on "InsertEnter" and see if that helps. I noticed you don't lazy load at all and you might be hitting some unknown race condition.

MikiVanousek commented 2 years ago

@crisidev I fixed it. As I use Lunar Vim, I had to change the package manager path.

require("copilot").setup {
    plugin_manager_path = "/home/miki/.local/share/lunarvim" .. "/site/pack/packer",
}

Also, for some reason the cmp configuration does not work if it is run as a packer config argument, it has to be outside it. The entire config looks something like this:

lvim.plugins = {
...
  { "zbirenbaum/copilot.lua",
    event = { "VimEnter" },
    config = function()
      vim.defer_fn(function()
        require("copilot").setup {
          plugin_manager_path = "/home/miki/.local/share/lunarvim" .. "/site/pack/packer",
        }
      end, 100)
    end,
  },

  { "zbirenbaum/copilot-cmp",
    after = { "copilot.lua", "nvim-cmp" },
    config = function()
    end
  },
}

vim.builtin.cmp.sources = {
  { name = "copilot", group_index = 2 },
  { name = "nvim_lsp", group_index = 2 },
  { name = "path", group_index = 2 },
  { name = "luasnip", group_index = 2 },
}

Don't forget to quit lvim, PackerSync, PackerCompile and quit again.

crisidev commented 2 years ago

Nice!! It works perfectly!