Skip to content

Commit 8f7465a

Browse files
committed
feat: add tab-local AIChat toggle and per-tab chat buffer reuse
1 parent 8cc8f6a commit 8f7465a

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ In the documentation below, `<selection>` denotes a visual selection or any oth
208208

209209
### `:AIChat`
210210

211-
`:AIChat` - open chat window on current tab, jump to it if already open, reopen it if hidden, close it when called from chat.
211+
`:AIChat` - open chat window on current tab, jump to it if already open, reopen it if hidden.
212212
Each tab keeps its own chat buffer.
213213

214214
`<selection>? :AIChat {instruction}?` - open or focus the tab-local chat and optionally initialize it with selection/instruction
215215

216216
`<selection>? :AIChat /{role} {instruction}?` - open/focus chat and apply role to chat initialization
217217

218-
Use `:AI` inside an `aichat` buffer to continue the conversation.
218+
Use `:AIChat` inside an `aichat` buffer to continue the conversation.
219219

220220
[Pre-defined](./roles-default.ini) chat roles: `/right`, `/below`, `/tab`
221221

autoload/vim_ai.vim

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function! s:ImportPythonModules()
2121
endfor
2222
endfunction
2323

24+
function! vim_ai#ImportPythonModules() abort
25+
call s:ImportPythonModules()
26+
endfunction
27+
2428
function! s:GetBufferWinIdInTab(bufnr, tabnr) abort
2529
for l:win_id in win_findbuf(a:bufnr)
2630
if win_id2tabwin(l:win_id)[0] == a:tabnr
@@ -50,14 +54,6 @@ function! s:IsBufferVisibleOutsideTab(bufnr, tabnr) abort
5054
return 0
5155
endfunction
5256

53-
function! s:CloseCurrentChatWindow() abort
54-
try
55-
hide close
56-
catch /^Vim\%((\a\+)\)\=:E444/
57-
enew
58-
endtry
59-
endfunction
60-
6157
" Configures ai-chat scratch window.
6258
" - scratch_buffer_keep_open = 0
6359
" - opens new ai-chat every time
@@ -299,11 +295,6 @@ function! s:ReuseOrCreateChatWindow(config)
299295
endfunction
300296

301297
function! vim_ai#AIChatToggleRun(uses_range, config, ...) range abort
302-
if &filetype ==# 'aichat'
303-
call s:CloseCurrentChatWindow()
304-
return
305-
endif
306-
307298
if a:0 > 0
308299
execute a:firstline . "," . a:lastline . "call vim_ai#AIChatRun(" . a:uses_range . ", " . string(a:config) . ", " . string(a:1) . ")"
309300
else

doc/vim-ai.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ https://platform.openai.com/docs/api-reference/completions
118118

119119
*:AIChat*
120120

121-
:AIChat open/focus tab-local chat window, or close it
122-
when called from an aichat buffer
121+
:AIChat open/focus tab-local chat window
123122
Each tab keeps its own chat buffer.
123+
In aichat buffers this continues the chat.
124124
<selection>? :AIChat {instruction}? open/focus tab-local chat and optionally
125125
initialize it using selection/instruction
126126

0 commit comments

Comments
 (0)