diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-02-27 21:23:12 +0100 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-02-27 21:26:18 +0100 |
| commit | 7849ee09c54008cf2b87cd8af7e694367d14c879 (patch) | |
| tree | 9680f237fda9e169e357d179e66e193b20cdafae | |
| parent | 5c1104c5dbd81b4574b2b5a6f3f27c0457ed529c (diff) | |
| download | vim-ai-7849ee09c54008cf2b87cd8af7e694367d14c879.tar.gz | |
docu
Diffstat (limited to '')
| -rw-r--r-- | README.md | 57 | ||||
| -rw-r--r-- | demo.gif | bin | 0 -> 770480 bytes | |||
| -rw-r--r-- | doc/vim-ai.txt | 25 |
3 files changed, 82 insertions, 0 deletions
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. + + + +## 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 <leader>a :AI<CR> +vnoremap <leader>a :AI<CR> +``` + +### 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 <leader>s :AI fix grammar and spelling and use formal language<CR> +nnoremap <leader>s :AI fix grammar and spelling and use formal language<CR> + +# command with custom context +command! -range -nargs=? AICode <line1>,<line2>call AIRun("Programming syntax is " . &filetype, <f-args>) +``` +## License + +[MIT License](https://github.com/madox2/vim-ai/blob/main/LICENSE) diff --git a/demo.gif b/demo.gif Binary files differnew file mode 100644 index 0000000..35817e0 --- /dev/null +++ b/demo.gif diff --git a/doc/vim-ai.txt b/doc/vim-ai.txt new file mode 100644 index 0000000..f4e3545 --- /dev/null +++ b/doc/vim-ai.txt @@ -0,0 +1,25 @@ +*vim-ai.txt* Complete text using OpenAI API. + +Author: Martin Bielik <https://madox2.poriadne.sk/> +License: see https://github.com/madox2/vim-ai/blob/main/LICENSE + +INTRODUCTION *vim-ai* + +This plugin can be used to generate code, edit text, brainstorm ideas, +translate, etc. + +COMMANDS *vim-ai-commands* + +To set-up key bindings and expamples see: +https://github.com/madox2/vim-ai + + *:AI* +: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. + +ABOUT *vim-ai-about* + +Contributions are welcome on GitHub: + +https://github.com/madox2/vim-ai |