diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-04-22 16:00:43 +0200 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-04-22 16:00:43 +0200 |
| commit | 12aae5adeaa393eecb424e9ffdc458616b2083f1 (patch) | |
| tree | d78357d2a1104a0d46e4af0ea99b13d8560f6423 /doc/vim-ai.txt | |
| parent | ad45ecff60461377788220da3b6f0ca8006f24cb (diff) | |
| download | vim-ai-12aae5adeaa393eecb424e9ffdc458616b2083f1.tar.gz | |
custom commands documentation
Diffstat (limited to '')
| -rw-r--r-- | doc/vim-ai.txt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/doc/vim-ai.txt b/doc/vim-ai.txt index 5cc0718..396fb95 100644 --- a/doc/vim-ai.txt +++ b/doc/vim-ai.txt @@ -143,6 +143,39 @@ Examples how configure key bindings and customize commands: > " redo last AI command nnoremap <leader>r :AIRedo<CR> +CUSTOM COMMANDS + +To create custom commands, call `AIRun`, `AIEditRun` and `AIChatRun` functions: > + + " custom command suggesting git commit message, takes no arguments + function! AIPromptCommitMessageFn() + let l:diff = system('git diff --staged') + let l:prompt = "generate a short commit message from the diff below:\n" . l:diff + let l:range = 0 + let l:config = { + \ "engine": "chat", + \ "options": { + \ "model": "gpt-3.5-turbo", + \ "initial_prompt": ">>> system\nyou are a code assistant", + \ "temperature": 1, + \ }, + \} + call vim_ai#AIRun(l:range, l:config, l:prompt) + endfunction + command! AIPromptCommitMessage call AIPromptCommitMessageFn() + + " custom command that provides a code review for selected code block + function! AIPromptCodeReviewFn(range) range + let l:prompt = "programming syntax is " . &filetype . ", review the code below" + let l:config = { + \ "options": { + \ "initial_prompt": ">>> system\nyou are a clean code expert", + \ }, + \} + '<,'>call vim_ai#AIChatRun(a:range, l:config, l:prompt) + endfunction + command! -range AIPromptCodeReview <line1>,<line2>call AIPromptCodeReviewFn(<range>) + ABOUT *vim-ai-about* Contributions are welcome on GitHub: |