An AI plugin that does the work for you.
This is a simple plugin for Vim that will allow you to use OpenAI Codex. To use this plugin you need to have access to OpenAI's Codex API.
The easiest way to install the plugin is to install it as a bundle. For example, using Pathogen:
-
Get and install pathogen.vim. You can skip this step if you already have it installed.
-
cd ~/.vim/bundle -
git clone git@github.com:tom-doerr/vim_codex.git
Bundle installs are known to work fine also when using Vundle. Other bundle managers are expected to work as well.
After installing the plugin, you need to install the openai package::
pip3 install openai
Finally add your OpenAI access information in
~/.vim/bundle/vim_codex/python/AUTH.py.
You can find your authentication information on the website.
The plugin provides a CreateCompletion command which you can call by default using the mapping
<Leader>co.
To complete the current text from insert and normal mode using Ctrl+x, you can add the following lines to your .vimrc::
nmap <C-x> :CreateCompletion<CR>
imap <C-x> <Esc>l:CreateCompletion<CR>i
In order to update the plugin, go to its bundle directory and use Git to update it:
-
cd ~/.vim/bundle/vim_codex -
git pull
Use the :BundleUpdate command provided by Vundle, for example invoking
Vim like this::
% vim +BundleUpdate