How to use Copilot Chat with Neovim!

Integrating Copilot Chat with Neovim

Intro

If you're a Neovim/Vim user who has been eagerly anticipating Copilot Chat, your wait might be over. There's been significant buzz about it in the community, as evidenced by the numerous comments in this discussion: copilot.vim support for copilot chat? 路 community 路 Discussion #50939

Context

A few weeks ago, a new and somewhat unpolished plugin surfaced. It's not an official release from the GitHub team, but rather a community-driven initiative. It caught my attention, and I decided to explore it. Written in Python, integrating this plugin into my Neovim configuration involved copying a few files and running UpdateRemotePlugins, followed by a Neovim restart.

Demo & Usage

For this demonstration, I'll be integrating the plugin using my fork with lazy.nvim:

{
    "CopilotC-Nvim/CopilotChat.nvim",
    opts = {},
    build = function()
      vim.cmd("UpdateRemotePlugins") -- You need to restart to make it works
    end,
    event = "VeryLazy",
    keys = {
      { "<leader>cce", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
      { "<leader>cct", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
    },
  }

To use it, simply yank code into the unnamed register and run CopilotChat to open a new buffer for an interactive chat session.

Demo

Roadmap and Future Enhancements

This plugin is still in its early stages, but it shows immense promise. A noteworthy development on the horizon is the addition of sub-commands, a feature requested by me on Feature Request: support sub-commands in CopilotChat.nvim 路 Issue #5 路 gptlang/CopilotChat.nvim. The author has acknowledged this request and plans to implement it soon, which is expected to significantly enhance the plugin's functionality and user experience.

Your feedback and trials are essential to its evolution, so I encourage you to give it a try and contribute to its ongoing development.