summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Bielik <martin.bielik@instea.sk>2024-12-17 21:09:53 +0100
committerMartin Bielik <martin.bielik@instea.sk>2024-12-17 21:09:53 +0100
commitdda1a41e00499ac9fd304bb87a1f521afa0fef1d (patch)
tree91720c60482a1107fed31a4a2b5c0b676088a7b1
parent93cd92aa0bba2ac34df3b25b124790434a0cd8b0 (diff)
downloadvim-ai-dda1a41e00499ac9fd304bb87a1f521afa0fef1d.tar.gz
new utility commands
Diffstat (limited to '')
-rw-r--r--README.md26
-rw-r--r--autoload/vim_ai.vim8
-rw-r--r--doc/vim-ai.txt13
-rw-r--r--plugin/vim-ai.vim3
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 <line1>,<line2>call vim_ai#AIChatRun(<range>, {}, <q-args>)
command! -nargs=? AINewChat call vim_ai#AINewChatDeprecatedRun(<f-args>)
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)