A neovim plugin for openai codex.
This plugin was also written with the help of codex.
In order for the plugin to work, you need to set the "OPENAI_API_KEY" environment variable to your api key (see openai introduction)
You also need (currently) to add a few packages to your nvim-python3 environment:
- openai package
- click
both can be installed with pip:
pip install click openai
For more information on python in nvim read the provider help
:help provider-python
call dein#add('ShoofLLC/vim-openai', {'merged': 0})
Plug 'ShoofLLC/vim-openai'
Plugin 'ShoofLLC/vim-openai'
NeoBundle 'ShoofLLC/vim-openai'
The plugin provides one command "CodexHelp". An example of how to map this command is found in vim_openai.vim
Visually select some text then press F7 to use the selected text as prompt to open ai codex.
You can also combine the text selection and the command in one go
" This command will select the entire file and send it to openai-codex
" Be careful not to use it on files containing sensitive information
nnoremap <c-n> gg0vG$h:<c-u>call CodexHelp(visualmode())<CR> " Map Ctrl-n
The python dependencies have to be installed manually.
This plugin has only been tested with nvim 0.5+, this is a very early version of the plugin so everything can go wrong.
This software is provided as is, with no warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
A lot of snippets were taken and modified from learn vimscript the hard way so I would like to thank the authors (Steve Losh).