From dda1a41e00499ac9fd304bb87a1f521afa0fef1d Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Tue, 17 Dec 2024 21:09:53 +0100 Subject: new utility commands --- README.md | 26 ++++++++++++++++++++------ autoload/vim_ai.vim | 8 ++++++++ doc/vim-ai.txt | 13 +++++++++++++ plugin/vim-ai.vim | 3 +++ 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1970b54..448c3b3 100644 --- a/README.md +++ b/README.md @@ -77,15 +77,18 @@ git clone https://github.com/madox2/vim-ai.git ~/.local/share/nvim/site/pack/plu To use an AI command, type the command followed by an instruction prompt. You can also combine it with a visual selection. Here is a brief overview of available commands: ``` -========= Basic AI commands ========= +=========== Basic AI commands ============ -:AI complete text -:AIEdit edit text -:AIChat continue or open new chat +:AI complete text +:AIEdit edit text +:AIChat continue or open new chat -============= Utilities ============= +=============== Utilities ================ -:AIRedo repeat last AI command +:AIRedo repeat last AI command +:AIUtilRolesOpen open role config file +:AIUtilDebugOn turn on debug logging +:AIUtilDebugOff turn off debug logging :help vim-ai ``` @@ -400,6 +403,17 @@ let g:vim_ai_chat = { " - setting max tokens to 0 will exclude it from the OpenAI API request parameters, it is " unclear/undocumented what it exactly does, but it seems to resolve issues when the model " hits token limit, which respond with `OpenAI: HTTPError 400` + + +" custom roles file location +let g:vim_ai_roles_config_file = s:plugin_root . "/roles-example.ini" + +" custom token file location +let g:vim_ai_token_file_path = "~/.config/openai.token" + +" debug settings +let g:vim_ai_debug = 0 +let g:vim_ai_debug_log_file = "/tmp/vim_ai_debug.log" ``` ### Using custom API diff --git a/autoload/vim_ai.vim b/autoload/vim_ai.vim index 87c825c..f3ec806 100644 --- a/autoload/vim_ai.vim +++ b/autoload/vim_ai.vim @@ -321,3 +321,11 @@ endfunction function! vim_ai#RoleCompletionChat(A,L,P) abort return s:RoleCompletion(a:A, 'chat') endfunction + +function! vim_ai#AIUtilRolesOpen() abort + execute "e " . g:vim_ai_roles_config_file +endfunction + +function! vim_ai#AIUtilSetDebug(is_debug) abort + let g:vim_ai_debug = a:is_debug +endfunction diff --git a/doc/vim-ai.txt b/doc/vim-ai.txt index 93ec3eb..0114699 100644 --- a/doc/vim-ai.txt +++ b/doc/vim-ai.txt @@ -155,6 +155,19 @@ paths. :AIRedo repeat last AI command in order to re-try or get an alternative completion. + *:AIUtilOpenRoles* + +:AIUtilOpenRoles open role configuration file + + *:AIUtilDebugOn* + +:AIUtilDebugOn turn on debug logging + + *:AIUtilDebugOff* + +:AIUtilDebugOff turn off debug logging + + CONFIGURATION *vim-ai-config* To customize the default configuration, initialize the config variable with diff --git a/plugin/vim-ai.vim b/plugin/vim-ai.vim index c826e8c..146504d 100644 --- a/plugin/vim-ai.vim +++ b/plugin/vim-ai.vim @@ -9,3 +9,6 @@ command! -range -nargs=? -complete=customlist,vim_ai#RoleCompletionEdit AIEdit < command! -range -nargs=? -complete=customlist,vim_ai#RoleCompletionChat AIChat ,call vim_ai#AIChatRun(, {}, ) command! -nargs=? AINewChat call vim_ai#AINewChatDeprecatedRun() command! AIRedo call vim_ai#AIRedoRun() +command! AIUtilRolesOpen call vim_ai#AIUtilRolesOpen() +command! AIUtilDebugOn call vim_ai#AIUtilSetDebug(1) +command! AIUtilDebugOff call vim_ai#AIUtilSetDebug(0) -- cgit v1.2.3