CodePartner is a Neovim plugin that provides AI-powered code explanations and assistance directly in your editor.
- Explain selected code snippets
- Follow-up questions and conversations about your code
- Customizable floating window for explanations
Screen.Recording.2024-08-26.at.2.25.30.AM.mov
- Neovim >= 0.7.0
- Python 3.7+
- Flask
- llm >= 0.14
Here are several ways to install CodePartner.nvim:
Using packer.nvim
use {
'sr1/codepartner.nvim',
config = function()
require('codepartner').setup({
api_key = 'your_api_key_here',
server_url = 'http://localhost:5000' -- Adjust if needed
auto_start_server = true -- Set to false if you want to start the server manually
})
end
}
Using vim-plug
Add the following to your init.vim:
Plug 'sr1/codepartner.nvim'
" After plug#end():
lua << EOF
require('codepartner').setup({
api_key = 'your_api_key_here',
server_url = 'http://localhost:5000' -- Adjust if needed
auto_start_server = true -- Set to false if you want to start the server manually
})
EOF
Using dein.vim
Add the following to your init.vim:
call dein#add('sr1/codepartner.nvim')
" After dein#end():
lua << EOF
require('codepartner').setup({
api_key = 'your_api_key_here',
server_url = 'http://localhost:5000' -- Adjust if needed
auto_start_server = true -- Set to false if you want to start the server manually
})
EOF
Using lazy.nvim
Add the following to your Neovim configuration:
{
'sr1/codepartner.nvim',
config = function()
require('codepartner').setup({
api_key = 'your_api_key_here',
server_url = 'http://localhost:5000' -- Adjust if needed
auto_start_server = true -- Set to false if you want to start the server manually
})
end
}
If you prefer to manually install the plugin:
- Clone the repository:
git clone https://github.com/sr1/codepartner.nvim.git \ ~/.local/share/nvim/site/pack/plugins/start/codepartner.nvim
- Add the following to your init.lua:
require('codepartner').setup({ api_key = 'your_api_key_here', server_url = 'http://localhost:5000' -- Adjust if needed auto_start_server = true -- Set to false if you want to start the server manually })
- Select the code you want to explain in visual mode
- Run
:ExplainSelection
to get an explanation - Use
<Leader>et
to toggle the explanation window - Use
<Leader>ec
to close the explanation window
You can customize the plugin by passing options to the setup function:
require('codepartner').setup({
api_key = 'your_api_key_here',
server_url = 'http://your_server_url:port'
auto_start_server = true -- Set to false if you want to start the server manually
})
By default, the server will start automatically when you open Neovim. You can manage the server using the following commands:
To start the server manually:
:StartCodePartner()
To stop the server:
:StopCodePartner()
The server runs as a background process. You can find its logs in the plugin's server directory (codepartner_server.log).