zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.45k stars 67 forks source link

copilot not producing panel completions #148

Closed bastianlb closed 1 year ago

bastianlb commented 1 year ago

I am having trouble generating consistent panel predictions from copilot. The "trace" logs in LSP completion seem to indicate this is an error from the api.

[TRACE][2023-04-11 11:04:28] .../lua/vim/lsp.lua:1053   "notification"  "LogMessage"    {  extra = { "Producing empty solutions due to document version mismatch. Panel completions requested for document version 791 but document version was 790." },  level = 0,  message = "[DEBUG] [getPanelCompletions] [2023-04-11T09:04:28.086Z] Producing empty solutions due to document version mismatch. Panel completions requested for document version 791 but document version was 790.",  metadataStr = "[DEBUG] [getPanelCompletions] [2023-04-11T09:04:28.086Z]"}

So apparently the document changes somehow in between calls, preventing panel completions. I've noticed that the panel calls get created successfully when I predict with my cursor at the end of the document.

Would anyone know the reason for this? I've tested it on both LTS and Dev nvim. I am using LunarVim.

mason.nvim report
- OK neovim version >= 0.7.0
- OK **npm**: `8.1.2`
- OK **node**: `v16.13.2`
- OK **python3**: `Python 3.9.10`
- OK **pip3**: `pip 23.0.1 from ... (python 3.9)`
- OK **wget**: `GNU Wget 1.20.3 built on linux-gnu.`
- OK **curl**: `curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3`
- OK **gzip**: `gzip 1.10`
- OK **tar**: `tar (GNU tar) 1.30`
- OK **bash**: `GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)`
- OK **sh**: `Ok`
- OK GitHub API rate limit. Used: 0. Remaining: 60. Limit: 60. Reset: Tue 11 Apr 2023 12:19:07 PM CEST.
MunifTanjim commented 1 year ago

How did you configure the plugin?

What's the output of :Copilot version?

bastianlb commented 1 year ago

Hi there, thanks for the quick response.

I configured the plugins as follows, as recommended for packer / lvim:

    {
    "zbirenbaum/copilot.lua",
    event = { "VimEnter" },
    config = function()
      vim.defer_fn(function()
        require("copilot").setup {
          plugin_manager_path = os.getenv "LUNARVIM_RUNTIME_DIR" .. "/site/pack/packer",
        }
      end, 100)
    end,
    },
    {
      "zbirenbaum/copilot-cmp",
      after = { "copilot.lua" },
      config = function()
        require("copilot_cmp").setup()
      end,
    },

The output of :Copilot version is:

Neovim 0.9.0
copilot.vim 1.8.3
copilot.lua e6e6433537bc42d9150bcad931d6fbd4aea3f751
copilot/dist/agent.js 1.73.0
Node.js 16.13.2
MunifTanjim commented 1 year ago

Can you try getting rid of the vim.defer_fn and see if the situation improves?

bastianlb commented 1 year ago

This unfortunately did not resolve the issue..

dancek commented 1 year ago

I have this issue too. Version info and packer config snippet below (or the full config).

Neovim 0.9.0                                                                
copilot.vim 1.8.3                                                           
copilot.lua decc8d43bcd73a288fa689690c20faf0485da217                        
copilot/dist/agent.js 1.73.0                                                
Node.js 19.9.0
  use {
    "zbirenbaum/copilot.lua",
    config = function ()
      require("copilot").setup()
    end
  }
  use {
    "zbirenbaum/copilot-cmp",
    after = { "copilot.lua" },
    config = function ()
      require("copilot_cmp").setup()
    end
  }
MunifTanjim commented 1 year ago

You might have some plugin that's changing the buffer after you open the copilot panel.

@dancek can you try disabling Pocco81/auto-save.nvim plugin and see if the issue still remains?

You can also try enabling panel auto_refresh, so that the panel automatically refreshes if buffer changes:

require("copilot").setup({
  -- other options
  panel = {
    -- other options
    auto_refresh = true,
  },
})
MunifTanjim commented 1 year ago

Let's reopen if this still exists.

piotryordanov commented 11 months ago

I still have the issue, tho i'm not sure how to debug it. FYI, i'm using coc with various plugins.

I also have the refresh set to true for he panel. Still, it just gets stuck at synthesizing ?/0 solutions

MunifTanjim commented 11 months ago

It might just be a network issue. Copilot server might have blocked your IP for some reason, or you network might have some firewall. You can also try signout and signin again... that sometimes solves the issue.

bastianlb commented 10 months ago

I'd like to propose to open this again as after some time away from vim I'm still unable to get panel completions to work. Completions via cmp work fine. However, I also don't get any error messages in logs that requests from copilot are failing, just a silent "Synthesizing ?/0 solutions (Duplicates hidden) [loading]" at which point the panel seems stuck.

Right now I'm using an out-of-the-box lazyvim config with all plugins and vim up to date.. Is anyone able to reproduce this? Would adding some error messages regarding failed copilot API requests be helpful here? I also tried this on several different networks with all VPNs disabled and re-authenticating Copilot.lua, to no avail.

Neovim 0.9.2 (also tried 0.10.0-dev)
copilot.vim 1.10.2
copilot.lua 2c942f33ba5c621c906e625e00a1bb504b65e2f0
copilot/dist/agent.js not running
Node.js 18.17.1

The only messages I get in my lsp.log are:

[START][2023-09-14 09:55:33] LSP logging initiated
[WARN][2023-09-14 09:55:33] ...lsp/handlers.lua:134     "The language server copilot triggers a registerCapability handler for workspace/didChangeWorkspaceFolders despite dynamicRegistration set to false. Report upstream, this warning is harmless"
MunifTanjim commented 10 months ago

copilot/dist/agent.js not running

Here the copilot server is not running at all.

bastianlb commented 10 months ago

Hey, thanks for the quick responses. I'm not sure why it wasn't running in this moment. I can generally reliably get cmp completions, just not panel completions.

image