How To Install The Codeium Plugin on Vim and Neovim
Introduction
In the world of programmers, neovim is one of the most used terminal based editor, of course others are vi, vim and emacs.
Unlike full fledged IDE (Internal Development Environment) with robust features and functionalities, often normal editors comes with just a simple interface for text and some keyboard commands.
Hence, just like how one can make use of plugins on IDE like VS Code, Pycharm, Atom etc. to improve the overall user experience and add more functionality on it, also one can do the same in His/Her terminal based editors too.
Today, we will be focusing more on neovim, which is one of the popular text based editor. We will see how we can install a plugin called Codeium, this plugin works just like Git Pilot, with an advantage of being free of charge for individuals, so for those that can't afford to pay for the Git Copilot, Codeium is here for you, most especially in this era of AI (Artificial Intelligence) and Machine Learning.
Install a Plugin Manager
The first step to installing Codeium on neovim or vim is to first of all install a Plugin Manager, here I will be illustrating for both vim and neovim:
For Vim
There are different plugin managers for vim like:
vim-plug
VAM (vim-addon-manager)
Vundle
vim-pathogen
However, out of these four, we will be making use of the vim-plug plugin manager, as that is the most popular one and that is what I myself is using.
First we need to install the vim-plug plugin manager, using the command below:
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
And viola, you now have your vim-plug plugin manager installed.
For Neovim
Just like with vim, there are also different plugin managers for neovim, but here we will be making use of the vim-plug as well, so to install the vim-plug plugin manager, you will have to run the command below:
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
And viola, you now have your vim-plug plugin manager installed.
Configuring and Installing The Codeium Plugin
For Vim
First you need to create a file called .vimrc in the home directory. You can do that using the command below:
sudo touch ~/.vimrc
Next, we will need to open the file using any terminal based editor of your choice, here I am using the vim editor. Also, remember to use the sudo command in opening the file so that you will open it in read and write mode and not as readonly file:
sudo vim ~/.vimrc
Next, configure the file as follows:
call plug#begin()
" the codium plugin
Plug 'Exafunction/codeium.vim', { 'branch': 'main' }
call plug#end()
Once you have defined the codeium plugin in the .vimrc file, the next step is to download and install it, using the command :PlugInstall
all from your vim.
Firstly, open your vim using the command:
vim
Next, while still in the command mode of your vim editor, type this command :PlugInstall
and press enter.
Now you are done installing codeium plugin on your vim, next is to set up the plugin and start using Codeium. This can be done by opening your vim and running the command :Codeium Auth
Once you press enter, you will be redirected to the Codeium website, which you will need to signup and login if you haven't done that before, once you are done logging in, you will see a token which you should copy
Tap on the copy icon to copy it and head back to your editor, where you will need to enter the token.
You paste the token at the bottom, where it is showing you to paste it and after that press enter, once that is done, the message will disappear.
You can now go ahead to close your vim editor and go ahead and test the power of Codeium.
For Neovim
First you need to create a file called init.vim
in the .config/nvim
directory. We will first have to create the directory .config/nvim
sudo mkdir ~/.config/nvim
Next, we will need to open the file using any terminal based editor of your choice, here I am using the nvim editor. Also, remember to use the sudo command in opening the file so that you will open it in read and write mode and not as readonly file:
sudo nvim ~/.config/nvim/init.vim
Next, configure the file as follows:
call plug#begin()
" the codium plugin
Plug 'Exafunction/codeium.vim', { 'branch': 'main' }
call plug#end()
Once you have defined the codeium plugin in the init.vim file, the next step is to download and install it, using the command :PlugInstall
all from your vim.
Firstly, open your neovim using the command:
nvim
Next, while still in the command mode of your neovim editor, type this command :PlugInstall
and press enter.
Now you are done installing codeium plugin on your vim, next is to set up the plugin and start using Codeium. This can be done by opening your vim and running the command :Codeium Auth
Once you press enter, you will be redirected to the Codeium website, which you will need to signup and login if you haven't done that before, once you are done logging in, you will see a token which you should copy
Tap on the copy icon to copy it and head back to your editor, where you will need to enter the token.
You paste the token at the bottom, where it is showing you to paste it and after that press enter, once that is done, the message will disappear.
You can now close your neovim editor and test the power of Codeium.
Testing The Power of Codeium
Here, I am going to be using neovim, just open a python or JavaScript file or whatsoever language of your choice as codeium supports a lot of programming languages including databases.
For this illustration, I am going to create a python file called calculator that adds, subtracts, multiplies and divides, and let's see the power of codeium at work:
Here, you will see the comment and code generated by Codeium being greyed out while the actual code in colour, once Codeium generate a code you want, you can simply press the tab button to accept that version of the code generated for you.
Conclusion
This is how easy it is to set up Codeium plugin for vim and neovim.
If there is any question you would love to ask concerning setting up codeium or using codeium, you can drop it in the comment section and I will do well to respond as soon as possible. Thank you.
Thank you for reading. You can connect with me on Twitter and LinkedIn.
Subscribe to my newsletter
Read articles from Gideon Bature directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Gideon Bature
Gideon Bature
A Seasoned Software Engineer and Technical Writer.