From 0faae7b1fbec281f5a645f25e5012d9deb307f56 Mon Sep 17 00:00:00 2001 From: Martin Bielik Date: Sun, 12 Mar 2023 19:47:21 +0100 Subject: getting rid of global dependencies --- plugin/vim-ai.vim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'plugin/vim-ai.vim') diff --git a/plugin/vim-ai.vim b/plugin/vim-ai.vim index 6c473b1..a5ded7a 100644 --- a/plugin/vim-ai.vim +++ b/plugin/vim-ai.vim @@ -33,9 +33,11 @@ function! AIRun(...) range if g:vim_ai_debug echo "Prompt:\n" . prompt . "\n" endif - echo "Completing..." - let output = system("echo " . shellescape(prompt) . " | python3 " . s:complete_py . " ") + " WORKAROUND: without sleep is echo on prev line not displayed (when combining with py3) + execute 'silent sleep 1m' + execute "py3file " . s:complete_py + let output = py3eval('output') let output = trim(output) execute "normal! " . a:lastline . "G" @@ -59,7 +61,10 @@ function! AIEditRun(...) range endif echo "Editing..." - let output = system("echo " . shellescape(prompt) . " | python3 " . s:complete_py . " ") + " WORKAROUND: without sleep is echo on prev line not displayed (when combining with py3) + execute 'silent sleep 1m' + execute "py3file " . s:complete_py + let output = py3eval('output') let output = trim(output) execute a:firstline . ',' . a:lastline . 'd' @@ -107,7 +112,10 @@ function! AIChatRun(...) range endif echo "Answering..." - let output = system("echo " . shellescape(prompt) . " | python3 " . s:chat_py . " ") + " WORKAROUND: without sleep is echo on prev line not displayed (when combining with py3) + execute 'silent sleep 1m' + execute "py3file " . s:chat_py + let output = py3eval('output') set paste execute "normal! ggdG" -- cgit v1.2.3