copilot-chat.lua
is a simple Neovim plugin for interacting with Copilot Chat.
Work in progress.
The plugin depends on plenary.nvim
and requires curl
to be installed.
A Copilot plugin, either copilot.lua
or copilot.vim
, needs to be authenticated.
return {
"somnam/copilot-chat.lua",
cmd = "CC",
cond = function()
return vim.fn.executable("curl") == 1
end,
dependencies = {
{ "nvim-lua/plenary.nvim" },
},
}
To use the plugin, follow these steps:
:CC <action>? <input>?
— Create a new chat buffer with optional input. Uses thedefault
chat action if none is provided.
Available Chat actions:
default[!]
- provide general suggestions or recommendations based on the input or context of the codeexplain[!]
- learn more about the concepts or techniques used in the selected coderefactor[!]
- improve the structure, readability, or performance of the codefix[!]
- identify and resolve bugs or problems in the codetests[!]
- request suggestions for writing tests for codenew
- request suggestions for creating a new projectworkspace
- help with tasks such as organizing files, configuring settings, or integrating external toolscommit
- generate commit messages
The current visual selection serves as context when executing the command.
Certain actions can be appended with an !
to use the current file as the command context instead of visual selection.
After running the command a new markdown buffer is populated with the chat contents.
To continue the chat write a response in the buffer and run the CC
command without any arguments.
Use visual mode to select a block of code and run :CC explain
.
Open a file and run :CC tests!
to have unit tests generated for the file contents.
Please feel free to open an issue or submit a pull request if you have suggestions for improvements.