/vim_codex_fauxpilot

Primary LanguagePythonMIT LicenseMIT

vim_codex_fauxpilot

This is a fork of vim_codex designed to work with fauxpilot. It is currently very simple; for more integrated support, see fauxpilot/fauxpilot#72. However I will continue to tinker with this repository for fun.

NOTE: you need to have the openai python library installed, otherwise the plugin will not work. Vim also has to be compiled with python support enabled.

ALSO NOTE: I disabled the "co" completion command as it seemed to be interfering with another plugin I had. I have these lines in my .vimrc for completion shortcuts for this plugin:

nnoremap  ,C a<Space><Esc>:CreateCompletion<CR>
nnoremap  ,c a<Space><Esc>:CreateCompletionLine<CR>

Information on vim_codex plugin:

🤖 Vim Codex

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 get access to OpenAI's Codex API.

Installation

The easiest way to install the plugin is to install it as a bundle. For example, using Pathogen:

  1. Get and install pathogen.vim. You can skip this step if you already have it installed.

  2. cd ~/.vim/bundle

  3. 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

After running :CreateCompletion once, the file ~/.config/openaiapirc is created where you need to enter your OpenAI authentication information. You can find your authentication information on the website.

Usage

The plugin provides a CreateCompletion command which you can call by default using the mapping <Leader>co. You can give the CreateCompletion command the number of tokens it should produce as an argument, e.g. CreateCompletion 1000. If you want to just complete the current line, run CreateCompletionLine.

To complete the current text from insert and normal mode using Ctrl+x, you can add the following lines to your .vimrc::

nnoremap  <C-x> :CreateCompletion<CR>
inoremap  <C-x> <Esc>li<C-g>u<Esc>l:CreateCompletion<CR>

Updating

Manually

In order to update the plugin, go to its bundle directory and use Git to update it:

  1. cd ~/.vim/bundle/vim_codex

  2. git pull

With Vundle

Use the :BundleUpdate command provided by Vundle, for example invoking Vim like this::

% vim +BundleUpdate

Traffic Statistics