jellydn / CopilotChat.nvim

Chat with GitHub Copilot in Neovim
GNU General Public License v3.0
100 stars 9 forks source link

Copilot chat stopped working, getting a load of python errors in recent versions #50

Closed admmasters closed 8 months ago

admmasters commented 8 months ago

Describe the bug

Getting the following error each time I try and interact with CopilotChat - this is new and it worked as expected up until the last couple of updates.

Using Lazyvim

Traceback (most recent call last):
  File "/Users/my.user/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-plugin.py", line 29, in copilot_agent_cmd
    self.vsplit_chat_handler.chat(args[0], file_type, code)
  File "/Users/my.user/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/handlers/vsplit_chat_handler.py", line 38, in chat
    super().chat(prompt, filetype, code, self.nvim.current.window.handle)
  File "/Users/my.user/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/handlers/chat_handler.py", line 47, in chat
    self._add_start_separator(system_prompt, prompt, code, filetype, winnr)
  File "/Users/my.user/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/handlers/chat_handler.py", line 82, in _add_start_separator
    self._add_regular_start_separator(
  File "/Users/my.user/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/handlers/chat_handler.py", line 114, in _add_regular_start_separator
    self._add_folds(code, code_height, last_row_before, system_prompt_height, winnr)
  File "/Users/my.user/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/handlers/chat_handler.py", line 173, in _add_folds
    self.nvim.command(full_command)
  File "/opt/homebrew/lib/python3.11/site-packages/pynvim/api/nvim.py", line 311, in command
    return self.request('nvim_command', string, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pynvim/api/nvim.py", line 199, in request
    res = self._session.request(name, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/pynvim/msgpack_rpc/session.py", line 139, in request
    raise self.error_wrapper(err)
pynvim.api.common.NvimError: Vim(fold):E350: Cannot create fold with current 'foldmethod'

Reproduction

Run CopilotChat <text>

System Info

System:
    OS: macOS 13.6.3
    CPU: (10) arm64 Apple M1 Max
    Memory: 541.86 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/Library/Caches/fnm_multishells/63871_1706948617636/bin/node
    npm: 10.1.0 - ~/Library/Caches/fnm_multishells/63871_1706948617636/bin/npm
    pnpm: 8.13.1 - ~/Library/Caches/fnm_multishells/63871_1706948617636/bin/pnpm
    bun: 1.0.18 - ~/.bun/bin/bun
    Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 121.0.6167.139
    Edge: 121.0.2277.98
    Safari: 17.1

Used Package Manager

pnpm

Validations

jellydn commented 8 months ago

Hi @admmasters, could share your configuration here? Please run ":UpdateRemotePlugins" command and restart Neovim. A new command, CopilotChatInPlace has released recently. Thanks.

admmasters commented 8 months ago

Ok so found the issue, looks like the config from the previous version I had installed needed updating. For anyone else who sees an issue like this:

This older config needed updating from:

return {
  "jellydn/CopilotChat.nvim",
  opts = {
    mode = "split", -- newbuffer or split  , default: newbuffer
  },
  build = function()
    vim.defer_fn(function()
      vim.cmd("UpdateRemotePlugins")
      vim.notify("CopilotChat - Updated remote plugins. Please restart Neovim.")
    end, 3000)
  end,
  event = "VeryLazy",
  keys = {
    { "<leader>cce", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
    { "<leader>cct", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
  },
}

New config which works for me:

return {
  {
    "gptlang/CopilotChat.nvim",
    dependencies = { "zbirenbaum/copilot.lua" }, -- Or { "github/copilot.vim" }
    opts = {
      mode = "split", -- newbuffer or split, default: newbuffer
      show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes
      debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log
    },
    build = function()
      vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.")
    end,
    event = "VeryLazy",
    keys = {
      { "<leader>cce", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
      { "<leader>cct", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
      -- Those are available only on canary branch
      {
        "<leader>ccv",
        ":CopilotChatVsplitVisual",
        mode = "x",
        desc = "CopilotChat - Open in vertical split",
      },
      {
        "<leader>ccx",
        ":CopilotChatInPlace<cr>",
        mode = "x",
        desc = "CopilotChat - Run in-place code",
      },
    },
  },
}

Closing as config error.

kristofka commented 8 months ago

From the stack trace this looks like it’s the same issue as in #56

It is now fixed in main and the config from the ReadMe should work as is.