From 12aae5adeaa393eecb424e9ffdc458616b2083f1 Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Sat, 22 Apr 2023 16:00:43 +0200 Subject: custom commands documentation --- doc/vim-ai.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'doc') 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 r :AIRedo +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 ,call AIPromptCodeReviewFn() + ABOUT *vim-ai-about* Contributions are welcome on GitHub: -- cgit v1.2.3