carrier.nvim is a Neovim plugin that integrates AI-powered editing suggestions directly into your editor. It supports multiple AI providers and offers enhanced editing capabilities.
It's designed to be turnkey: put in your API key, and you're ready to go. carrier.nvim handles the rest.
- AI-powered editing suggestions
- Support for multiple AI providers (OpenAI, Claude, Azure, DeepSeek)
- In-place editing suggestions with diff view
- Easy accept/reject mechanism for suggested edits
Install carrier.nvim using your preferred package manager. Here's an example using lazy.nvim:
{
"CamdenClark/carrier.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
require("carrier").setup({
-- Your configuration options here
})
end,
}
carrier.nvim has turnkey configuration for multiple AI providers. Configure carrier.nvim in your Neovim configuration:
require("carrier").setup({
provider = "deepseek", -- or "openai", "claude", "azure"
config = {
-- Provider-specific configuration
},
})
To use OpenAI's models:
require("carrier").setup({
provider = "openai",
config = {
api_key = vim.env.OPENAI_API_KEY,
model = "gpt-4", -- or "gpt-3.5-turbo-16k", "gpt-4-32k", etc.
},
})
Make sure to set your OPENAI_API_KEY
environment variable or provide it directly in the configuration.
For Anthropic's Claude:
require("carrier").setup({
provider = "claude",
config = {
api_key = vim.env.ANTHROPIC_API_KEY,
},
})
To use Azure OpenAI:
require("carrier").setup({
provider = "azure",
config = {
api_key = vim.env.AZURE_OPENAI_API_KEY,
endpoint = vim.env.AZURE_OPENAI_ENDPOINT,
deployment_name = "your-deployment-name",
},
})
For DeepSeek models:
require("carrier").setup({
provider = "deepseek",
config = {
api_key = vim.env.DEEPSEEK_API_KEY,
},
})
carrier.nvim provides several commands for AI-assisted editing:
-
Suggest Edit:
- Visual mode: Select the text you want to edit, then run
:CarrierSuggestEdit
. - You'll be prompted to enter an edit instruction.
- Visual mode: Select the text you want to edit, then run
-
Suggest Addition:
- Place your cursor where you want to add text, then run
:CarrierSuggestAddition
.
- Place your cursor where you want to add text, then run
-
Accept Suggestion:
- After reviewing the suggested edit in the diff view, run
:CarrierAccept
to apply the changes.
- After reviewing the suggested edit in the diff view, run
-
Reject Suggestion:
- If you don't want to apply the suggested changes, run
:CarrierReject
.
- If you don't want to apply the suggested changes, run
-
Cancel Operation:
- To cancel the current suggestion process, use
:CarrierCancel
.
- To cancel the current suggestion process, use
You can set up key mappings for these commands in your Neovim configuration. For example:
vim.api.nvim_set_keymap('v', '<leader>ce', ':CarrierSuggestEdit<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ca', ':CarrierSuggestAddition<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>cy', ':CarrierAccept<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>cn', ':CarrierReject<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>cc', ':CarrierCancel<CR>', { noremap = true, silent = true })
- When you request an edit or addition, carrier.nvim sends your selected text (for edits) or surrounding context (for additions) to the configured AI provider.
- The AI generates a suggestion, which is displayed in a new buffer as a diff view.
- You can review the changes in the diff view. Lines in green are additions, and lines in red are removals.
- Accept the changes to apply them to your original buffer, or reject them to close the diff view without making changes.
Running tests requires plenary.nvim to be checked out in the parent directory of this repository.
To run all tests:
make test
or, more verbose:
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests {minimal_init = 'tests/minimal.vim'}"
To run a single test file:
make test-file FILE=chat_spec.lua
or, more verbose:
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/chat_spec.lua {minimal_init = 'tests/minimal.vim'}"
Replace chat_spec.lua
with the path to your specific test file, relative to the tests/
directory.
Read the nvim-lua-guide for more information on developing Neovim plugins.
Contributions to carrier.nvim are welcome! Please feel free to submit pull requests or create issues on the GitHub repository.
MIT