diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2023-02-27 20:28:37 +0100 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2023-02-27 21:26:18 +0100 |
| commit | 041ad5739c5e55493c9feafa92be0b281a0ed2dc (patch) | |
| tree | bd8915c2000b2d97de03e605945d8e80411cebfb /vim-ai.vim | |
| parent | 718d1751e687e54108af963a48a350b939beb861 (diff) | |
| download | vim-ai-041ad5739c5e55493c9feafa92be0b281a0ed2dc.tar.gz | |
plugin dir
Diffstat (limited to 'vim-ai.vim')
| -rw-r--r-- | vim-ai.vim | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/vim-ai.vim b/vim-ai.vim deleted file mode 100644 index e02936c..0000000 --- a/vim-ai.vim +++ /dev/null @@ -1,28 +0,0 @@ -let g:openaiToken = system("cat ~/.config/openai.token") - -function! AIRun(...) range - let prompt = getline(a:firstline, a:lastline) - if a:0 - " join arguments and prepend to the prompt - let instruction = join(a:000, ", ") . ":" - call insert(prompt, instruction, 0) - endif - - let buff_lastline = line('$') - let prompt = join(prompt, "\n") - - echo "Completing..." - let output = system("echo " . shellescape(prompt) . " | openai complete - -t " . g:openaiToken) - let output = trim(output) - - execute a:firstline . ',' . a:lastline . 'd' - - if a:lastline == buff_lastline - execute "normal! o" . output . "\<Esc>" - else - execute "normal! O" . output . "\<Esc>" - endif - -endfunction - -command! -range -nargs=? AI <line1>,<line2>call AIRun(<f-args>) |