diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-04-15 11:48:37 +0200 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-04-15 11:48:57 +0200 |
| commit | 8f6c7ae590b179f2ec02142f57b2e9c3e81ac9fe (patch) | |
| tree | 63b0b8bbc9d0c4c98ff59babe2cf99bbf6609eaf /autoload/vim_ai.vim | |
| parent | d0ee7cfb0215509d64d47f35e6df2d2763e62557 (diff) | |
| download | vim-ai-8f6c7ae590b179f2ec02142f57b2e9c3e81ac9fe.tar.gz | |
scratch buffer options
Diffstat (limited to 'autoload/vim_ai.vim')
| -rw-r--r-- | autoload/vim_ai.vim | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/autoload/vim_ai.vim b/autoload/vim_ai.vim index 4957c5b..bfe4f3e 100644 --- a/autoload/vim_ai.vim +++ b/autoload/vim_ai.vim @@ -1,6 +1,32 @@ +" Configures ai-chat scratch window. +" - scratch_buffer_keep_open = 0 +" - opens new ai-chat every time +" - scratch_buffer_keep_open = 1 +" - opens last ai-chat buffer +" - keeps the buffer in the buffer list function! vim_ai#MakeScratchWindow() + let l:keep_open = g:vim_ai_chat['ui']['scratch_buffer_keep_open'] + if l:keep_open && bufexists("[AI chat]") + " reuse chat buffer + buffer \[AI chat\] + return + endif setlocal buftype=nofile - setlocal bufhidden=hide setlocal noswapfile setlocal ft=aichat + if l:keep_open + setlocal bufhidden=hide + else + setlocal bufhidden=wipe + endif + if bufexists("[AI chat]") + " spawn another window if chat already exist + let l:index = 2 + while bufexists("[AI chat " . l:index . "]") + let l:index += 1 + endwhile + execute "file [AI chat ". l:index . "]" + else + file [AI chat] + endif endfunction |