AI Assist in Neovim, Copilot, Codeium, and ChatGPT in 2024
TL;DR — Copilot is still the best inline-completion experience. Codeium is the best free alternative, especially for non-paid contexts. ChatGPT.nvim covers the “explain this code” workflow that ghost-text completion can’t. You probably want one of the first two plus something like ChatGPT.nvim for longer-form interaction.
I was skeptical about AI in the editor for longer than most people. I’m still skeptical about a lot of the marketing. But two years in, I won’t code without inline completion, and the in-editor chat workflow has replaced about 80% of my browser tab switches to ChatGPT.
This post is a pragmatic comparison of the three integrations I’ve actually used in production for the last year. I’ll cover what each one does well, where it falls down, and the configs that work in April 2024.
I’ll skip the “is AI good or bad for developers” debate. If you’ve decided to use one of these, this is how to set it up.
What’s Different in 2024
Three things changed since the 2022 wave of editor AI plugins.
The Lua plugins matured. Earlier integrations were mostly Node-based proxies that felt grafted on. Plugins like copilot.lua and codeium.nvim are now native Lua, integrate cleanly with nvim-cmp, and have lazy-loading specs that don’t tank startup.
The models got noticeably better. The autocomplete quality of Copilot or Codeium in 2024 is meaningfully better than 2022. For boilerplate, test scaffolding, and tedious-but-not-novel code, the suggestions are usually right.
The chat workflows became viable. ChatGPT.nvim, gen.nvim, and similar plugins let you select code, ask a question, and stream the answer back into a buffer. This is the workflow that pulled me off the ChatGPT browser tab.
Copilot, the Default Recommendation
Copilot remains the strongest inline completion experience. The model is good, latency is low, and the editor integration via copilot.lua is mature.
-- lua/plugins/copilot.lua
return {
{ 'zbirenbaum/copilot.lua',
cmd = 'Copilot',
event = 'InsertEnter',
opts = {
suggestion = {
auto_trigger = true,
keymap = {
accept = '<C-y>',
accept_word = '<C-l>',
next = '<C-n>',
prev = '<C-p>',
dismiss = '<C-]>',
},
},
panel = { enabled = false },
filetypes = {
markdown = true,
gitcommit = true,
yaml = true,
['.'] = false,
},
} },
}
A few opinionated choices in there.
I disable the panel. The inline ghost text is enough, the panel just adds another thing to dismiss.
I enable markdown and gitcommit. Copilot is genuinely useful for writing tests, docs, and commit messages, which it does well even if you don’t want it touching your source.
<C-y> to accept instead of <Tab>. Tab conflicts with completion menu navigation in nvim-cmp. Using <C-y> (which is roughly “yank line up” in default Vim but rarely used) gives you a dedicated key.
The pricing is the catch. Copilot is $10/month individual or $19/month business. If your employer pays, easy. If not, weigh it against the alternatives.
Codeium, the Free Alternative
Codeium is the best free option I’ve used. It’s not quite Copilot quality, but it’s close enough that the difference doesn’t matter for 90% of completions, and the price is right.
-- lua/plugins/codeium.lua
return {
{ 'Exafunction/codeium.nvim',
event = 'InsertEnter',
dependencies = { 'nvim-lua/plenary.nvim', 'hrsh7th/nvim-cmp' },
config = function()
require('codeium').setup({})
vim.keymap.set('i', '<C-y>', function() return vim.fn['codeium#Accept']() end, { expr = true })
vim.keymap.set('i', '<C-n>', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true })
vim.keymap.set('i', '<C-p>', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true })
vim.keymap.set('i', '<C-]>', function() return vim.fn['codeium#Clear']() end, { expr = true })
end },
}
The keymaps intentionally mirror the Copilot setup, so if you switch tools, your fingers don’t have to relearn.
First run prompts you to authenticate via a browser-based flow. After that, it just works. No subscription, no card on file, no rate limits I’ve hit in normal use.
Where Codeium falls short of Copilot, in my experience, is in larger contexts. When you’re working in a single function, both are comparable. When you’re three files deep into a project and the right completion depends on understanding code elsewhere, Copilot tends to do better. Worth noting if your work involves a lot of cross-file context.
You can run both, briefly, to compare on your own codebase. Don’t keep both enabled long-term, they’ll fight over completion slots and produce confusing UI.
ChatGPT.nvim for the Chat Workflow
Inline completion is one half of AI-assisted editing. The other half is the conversational workflow, “explain this,” “refactor this,” “what’s wrong with this,” “write a test for this.” ChatGPT.nvim covers that.
-- lua/plugins/chatgpt.lua
return {
{ 'jackMort/ChatGPT.nvim',
event = 'VeryLazy',
dependencies = {
'MunifTanjim/nui.nvim',
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
},
config = function()
require('chatgpt').setup({
api_key_cmd = 'op read op://Personal/openai/api-key', -- 1Password CLI
openai_params = { model = 'gpt-4-turbo', max_tokens = 1024 },
})
local map = vim.keymap.set
map({ 'n', 'v' }, '<leader>cc', '<cmd>ChatGPT<cr>')
map('v', '<leader>ce', '<cmd>ChatGPTEditWithInstruction<cr>')
map('v', '<leader>cx', '<cmd>ChatGPTRun explain_code<cr>')
map('v', '<leader>ct', '<cmd>ChatGPTRun add_tests<cr>')
end },
}
The api_key_cmd pulls the API key from 1Password’s CLI. Don’t put your API key in your config file in plaintext. If you don’t use 1Password, use pass, gopass, or read from an env var, anything but a literal string in dotfiles.
The four keymaps cover most of what I do. <leader>cc opens a chat buffer. <leader>ce (on a visual selection) lets you describe a transformation and applies it to the selection. <leader>cx explains the selected code. <leader>ct writes tests.
You pay OpenAI per token, which is the main difference from Copilot’s flat monthly fee. For my usage (maybe 5-10 conversations a day, mostly short), it works out to under $5/month, which is fine.
If you’d rather use Claude or a self-hosted model, gen.nvim, parrot.nvim, or avante.nvim give you similar workflows pointed at different backends. The patterns are the same.
I touched on the broader workflow in From VS Code to Neovim in 30 days, AI assist is best added once your editor fundamentals are stable, not on day one.
How I Actually Use This
A typical session breaks down something like.
Inline completion (Copilot or Codeium) handles roughly 30% of my keystrokes. Mostly boilerplate, test setup, type declarations, repeated patterns. I accept maybe half of what it suggests.
Chat (ChatGPT.nvim) gets used maybe 5-10 times a day for things that don’t fit ghost text. “I’m getting this Go error, what does it actually mean?” “Refactor this SQL into a CTE.” “Why is this test flaky?” Most of these used to be browser tabs.
Neither tool gets used for designing systems, picking architecture, or deciding what to build. They’re not good at that and treating them like they are leads to mediocre output.
Common Pitfalls
A few traps.
- Letting AI dictate code style. Inline completion suggests what the model has seen most often, which is not necessarily what your codebase looks like. Set up your linter and formatter to enforce your style, then accept completions only when they fit.
- Pasting secrets into chat. If your chat tool sends prompts to a hosted API, treat that prompt like a public Slack message. Don’t paste env vars, tokens, or customer data. Most plugins have a config option for “redact this,” use it.
- Disabling completion in passwords / secrets files. Add
gitcommit = truebut add a filetype exclusion fordotenvand similar. You don’t want ghost text suggesting plausible-looking credentials. - Two completers active at once. Copilot and Codeium will both try to render ghost text, and one ends up overlapping the other. Pick one.
- Trusting numerical output. AI completion is great at structure, mediocre at arithmetic. If it generates a constant, verify it. I’ve seen Copilot suggest a “correct” looking magic number that was simply wrong.
Wrapping Up
The state of AI in Neovim in 2024 is good. Copilot for inline if you can pay, Codeium if you can’t, plus ChatGPT.nvim (or equivalent) for chat-style queries. That covers the workflows that justify the tool.
What it won’t do is design your system, write your tests for the edge cases you didn’t think of, or replace deep reading of the code. Treat it as autocomplete on steroids, not as a coworker.
The copilot.lua repository is the canonical reference for the Copilot integration, and Codeium’s official docs cover authentication and troubleshooting. Worth bookmarking when something breaks at 3 AM.