diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-04-02 22:25:03 +0200 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-04-02 22:32:13 +0200 |
| commit | 779067beb18ddce9143a5fa9abf8608d921feeb4 (patch) | |
| tree | 07a5e45b3a6a2822bafd3e2e40cfd857e790dd94 /plugin/vim-ai.vim | |
| parent | 541fb8637f725c49e9cf3bf736387d0578c3af45 (diff) | |
| download | vim-ai-779067beb18ddce9143a5fa9abf8608d921feeb4.tar.gz | |
open chat command config
Diffstat (limited to '')
| -rw-r--r-- | plugin/vim-ai.vim | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/plugin/vim-ai.vim b/plugin/vim-ai.vim index 501dc2c..c32fb2f 100644 --- a/plugin/vim-ai.vim +++ b/plugin/vim-ai.vim @@ -21,6 +21,9 @@ let g:vim_ai_chat_default = { \ "temperature": 1, \ "request_timeout": 20, \ }, +\ "ui": { +\ "open_chat_command": "below new | call vim_ai#MakeScratchWindow()" +\ }, \} if !exists('g:vim_ai_complete') let g:vim_ai_complete = {"options":{}} @@ -29,10 +32,9 @@ if !exists('g:vim_ai_edit') let g:vim_ai_edit = {"options":{}} endif if !exists('g:vim_ai_chat') - let g:vim_ai_chat = {"options":{}} + let g:vim_ai_chat = {"options":{}, "ui": {}} endif - let s:plugin_root = expand('<sfile>:p:h:h') let s:complete_py = s:plugin_root . "/py/complete.py" let s:chat_py = s:plugin_root . "/py/chat.py" @@ -42,14 +44,6 @@ let s:last_is_selection = 0 let s:last_instruction = "" let s:last_command = "" -function! ScratchWindow() - below new - setlocal buftype=nofile - setlocal bufhidden=hide - setlocal noswapfile - setlocal ft=aichat -endfunction - function! MakePrompt(is_selection, lines, instruction) let lines = trim(join(a:lines, "\n")) let instruction = trim(a:instruction) @@ -104,7 +98,8 @@ function! AIChatRun(is_selection, ...) range set paste let is_outside_of_chat_window = search('^>>> user$', 'nw') == 0 if is_outside_of_chat_window - call ScratchWindow() + let ui_options = extend(copy(g:vim_ai_chat_default['ui']), g:vim_ai_chat['ui']) + execute ui_options['open_chat_command'] let prompt = "" if a:0 || a:is_selection let instruction = a:0 ? a:1 : "" |