From 7849ee09c54008cf2b87cd8af7e694367d14c879 Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Mon, 27 Feb 2023 21:23:12 +0100 Subject: docu --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..3596cce --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# vim-ai + +Complete text in vim using OpenAI. + +![vim-ai demo](./demo.gif) + +## Installation + +Prerequisites: + +```sh +# install https://github.com/peterdemin/openai-cli +pip install openai-cli + +# configure openai api key https://platform.openai.com/account/api-keys +echo "YOUR_OPENAPI_TOKEN" > ~/.config/openai.token + +# alternatively using environment variable +export OPENAI_API_TOKEN="YOUR_OPENAPI_TOKEN" +``` + +Add plugin to your `.vimrc`, e.g. using `vim-plug`: + +```vimscript +Plug 'madox2/vim-ai' +``` + +## Usage + +### Basic usage + +`:AI {prompt}` - completes selected text (visual mode) or text on the current line (normal mode). Passing optional `{prompt}` parameter prepends it to the final prompt. + +### Key bindings + +Map keys in your `.vimrc` to trigger `:AI` command. + +```vimscript +nnoremap a :AI +vnoremap a :AI +``` + +### Custom commands + +To customize and re-use prompts it is useful to put some context to the language model. You can do it with prepending text to `:AI` command. + +```vimscript +# key binding with custom context +vnoremap s :AI fix grammar and spelling and use formal language +nnoremap s :AI fix grammar and spelling and use formal language + +# command with custom context +command! -range -nargs=? AICode ,call AIRun("Programming syntax is " . &filetype, ) +``` +## License + +[MIT License](https://github.com/madox2/vim-ai/blob/main/LICENSE) -- cgit v1.2.3