From 9d43ef6c4966705376af2cd16fb012d020ce673d Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Sun, 8 Dec 2024 23:15:33 +0100 Subject: don't include not selected line, refactor ranges, fixes #112 --- plugin/vim-ai.vim | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'plugin/vim-ai.vim') diff --git a/plugin/vim-ai.vim b/plugin/vim-ai.vim index 1ed5326..d27f312 100644 --- a/plugin/vim-ai.vim +++ b/plugin/vim-ai.vim @@ -4,19 +4,8 @@ if !has('python3') finish endif -" detect if a visual selection is pending: https://stackoverflow.com/a/20133772 -let g:vim_ai_is_selection_pending = 0 -augroup vim_ai - autocmd! - autocmd CursorMoved * - \ let g:vim_ai_is_selection_pending = mode() =~# "^[vV\]" -augroup END - -command! -range -nargs=? -complete=customlist,vim_ai#RoleCompletion AI ,call vim_ai#AIRun({}, ) -command! -range -nargs=? -complete=customlist,vim_ai#RoleCompletion AIEdit ,call vim_ai#AIEditRun({}, ) -" Whereas AI and AIEdit default to passing the current line as range -" AIChat defaults to passing nothing which is achieved by -range=0 and passing -" as described at https://stackoverflow.com/a/20133772 -command! -range=0 -nargs=? -complete=customlist,vim_ai#RoleCompletion AIChat ,call vim_ai#AIChatRun(, {}, ) -command! -nargs=? AINewChat call vim_ai#AINewChatRun() -command! AIRedo call vim_ai#AIRedoRun() +command! -range -nargs=? -complete=customlist,vim_ai#RoleCompletion AI ,call vim_ai#AIRun(, {}, ) +command! -range -nargs=? -complete=customlist,vim_ai#RoleCompletion AIEdit ,call vim_ai#AIEditRun(, {}, ) +command! -range -nargs=? -complete=customlist,vim_ai#RoleCompletion AIChat ,call vim_ai#AIChatRun(, {}, ) +command! -nargs=? AINewChat call vim_ai#AINewChatRun() +command! AIRedo call vim_ai#AIRedoRun() -- cgit v1.2.3