Free, ultrafast Copilot alternative for Vim and Neovim
Codeium autocompletes your code with AI in all major IDEs. Welaunchedthis implementation of the Codeium plugin for Vim and Neovim to bring this modern coding superpower to more developers. Check out ourplaygroundif you want to quickly try out Codeium online.
Contributions are welcome! Feel free to submit pull requests and issues related to the plugin.
-
Install
Exafunction/codeium.vim
using your vim plugin manager of choice, or manually. SeeInstallation Optionsbelow. -
Run
:Codeium Auth
to set up the plugin and start using Codeium.
You can run:help codeium
for a full list of commands and configuration
options, or seethis guidefor a quick tutorial on how to use Codeium.
For a full list of configuration options you can run:help codeium
.
A few of the most popular options are highlighted below.
Codeium provides the following functions to control suggestions:
Action | Function | Default Binding |
---|---|---|
Clear current suggestion | codeium#Clear() |
<C-]> |
Next suggestion | codeium#CycleCompletions(1) |
<M-]> |
Previous suggestion | codeium#CycleCompletions(-1) |
<M-[> |
Insert suggestion | codeium#Accept() |
<Tab> |
Manually trigger suggestion | codeium#Complete() |
<M-Bslash> |
Accept word from suggestion | codeium#AcceptNextWord() |
<C-k> |
Accept line from suggestion | codeium#AcceptNextLine() |
<C-l> |
Codeium's default keybindings can be disabled by setting
letg:codeium_disable_bindings=1
or in Neovim:
vim.g.codeium_disable_bindings=1
If you'd like to just disable the<Tab>
binding, you can alternatively
use theg:codeium_no_map_tab
option.
If you'd like to bind the actions above to different keys, this might look something like the following in Vim:
imap<script><silent><nowait><expr><C-g>codeium#Accept()
imap<script><silent><nowait><expr><C-h>codeium#AcceptNextWord()
imap<script><silent><nowait><expr><C-j>codeium#AcceptNextLine()
imap<C-;><Cmd>call codeium#CycleCompletions(1)<CR>
imap<C-,><Cmd>call codeium#CycleCompletions(-1)<CR>
imap<C-x><Cmd>call codeium#Clear()<CR>
Or in Neovim (usingwbthomason/packer.nvimorfolke/lazy.nvim):
--Remove the `use` here if you're using folke/lazy.nvim.
use{
'Exafunction/codeium.vim',
config=function()
--Change '<C-g>' here to any keycode you like.
vim.keymap.set('i','<C-g>',function()returnvim.fn['codeium#Accept']()end,{expr=true,silent=true})
vim.keymap.set('i','<c-;>',function()returnvim.fn['codeium#CycleCompletions'](1)end,{expr=true,silent=true})
vim.keymap.set('i','<c-,>',function()returnvim.fn['codeium#CycleCompletions'](-1)end,{expr=true,silent=true})
vim.keymap.set('i','<c-x>',function()returnvim.fn['codeium#Clear']()end,{expr=true,silent=true})
end
}
(Make sure that you ran:Codeium Auth
after installation.)
Codeium can be disabled for particular filetypes by setting the
g:codeium_filetypes
variable in your vim config file (vimrc/init.vim):
letg:codeium_filetypes={
\"bash":v:false,
\"typescript":v:true,
\}
Codeium is enabled by default for most filetypes.
You can alsodisablecodeium by default with theg:codeium_enabled
variable,
and enable it manually per buffer by running:CodeiumEnable
:
letg:codeium_enabled=v:false
or in Neovim:
vim.g.codeium_enabled=false
Or you can disable codeium forall filetypeswith theg:codeium_filetypes_disabled_by_default
variable,
and use theg:codeium_filetypes
variable to selectively enable codeium for specified filetypes:
"let g:codeium_enabled = v:true
letg:codeium_filetypes_disabled_by_default=v:true
letg:codeium_filetypes={
\"rust":v:true,
\"typescript":v:true,
\}
If you would like to just disable the automatic triggering of completions:
letg:codeium_manual=v:true
"You might want to use `CycleOrComplete()` instead of `CycleCompletions(1)`.
"This will make the forward cycling of suggestions also trigger the first
"suggestion manually.
imap<C-;><Cmd>call codeium#CycleOrComplete()<CR>
To disable automatic text rendering of suggestions (the gray text that appears for a suggestion):
letg:codeium_render=v:false
Codeium status can be generated by calling thecodeium#GetStatusString()
function. In
Neovim, you can usevim.api.nvim_call_function( "codeium#GetStatusString", {})
instead.
It produces a 3 char long string with Codeium status:
'3/8'
- third suggestion out of 8'0'
- Codeium returned no suggestions'*'
- waiting for Codeium response
In normal mode, status shows if Codeium is enabled or disabled by showing
'ON'
or'OFF'
.
In order to show it in status line add following line to your.vimrc
:
set statusline+=\{…\}%3{codeium#GetStatusString()}
Shorter variant without Codeium logo:
set statusline+=%3{codeium#GetStatusString()}
Please check:help statusline
for further information about building statusline in VIM.
vim-airline supports Codeium out-of-the-box since commit3854429d.
Calling thecodeium#Chat()
function or using theCodeium Chat
command will enable search and inde xing in the current project and launch Codeium Chat in a new browser window.
:callcodeium#Chat()
:Codeium Chat
The project root is determined by looking in Vim's current working directory for some specific files or directories to be present and goes up to parent directories until one is found. This list of hints is user-configurable and the default value is:
let g:codeium_workspace_root_hints = ['.bzr','.git','.hg','.svn','_FOSSIL_','package.json']
Note that launching chat enables telemetry.
{
'Exafunction/codeium.vim',
event='BufEnter'
}
Plug'Exafunction/codeium.vim',{'branch':'main'}
Plugin'Exafunction/codeium.vim'
use'Exafunction/codeium.vim'
Run the following. On windows, you can replace~/.vim
with
$HOME/vimfiles
:
git clone https://github /Exafunction/codeium.vim~/.vim/pack/Exafunction/start/codeium.vim
Run the following. On windows, you can replace~/.config
with
$HOME/AppData/Local
:
git clone https://github /Exafunction/codeium.vim~/.config/nvim/pack/Exafunction/start/codeium.vim