1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
*vim-ai.txt* Complete text using OpenAI API.
Author: Martin Bielik <https://madox2.poriadne.sk/>
License: see https://github.com/madox2/vim-ai/blob/main/LICENSE
INTRODUCTION *vim-ai*
This plugin can be used to generate code, edit text, brainstorm ideas,
translate, etc.
COMMANDS *vim-ai-commands*
To set-up key bindings and expamples see:
https://github.com/madox2/vim-ai
*:AI*
:AI complete the text on the current line
:AI {prompt} complete the prompt
(selection) :AI complete the selection
(selection) :AI {instruction} complete the selection using the instruction
Options: >
let g:vim_ai_complete = {
\ "options": {
\ "model": "text-davinci-003",
\ "max_tokens": 1000,
\ "temperature": 0.1,
\ "request_timeout": 10,
\ },
\}
Check OpenAI docs for more infomration:
https://platform.openai.com/docs/api-reference/completions
*:AIEdit*
(selection)? :AIEdit edit the current line or the selection
(selection)? :AIEdit {instruction} edit the current line or the selection using
the instruction
Options: >
let g:vim_ai_edit = {
\ "options": {
\ "model": "text-davinci-003",
\ "max_tokens": 1000,
\ "temperature": 0.1,
\ "request_timeout": 10,
\ },
\}
Check OpenAI docs for more infomration:
https://platform.openai.com/docs/api-reference/completions
*:AIChat*
:AIChat continue or start a new conversation.
(selection)? :AIChat {instruction}? start a new conversation given the selection,
the instruction or both
Options: >
let g:vim_ai_chat = {
\ "options": {
\ "model": "gpt-3.5-turbo",
\ "max_tokens": 1000,
\ "temperature": 1,
\ "request_timeout": 10,
\ },
\}
Check OpenAI docs for more infomration:
https://platform.openai.com/docs/api-reference/chat
*:AIRedo*
:AIRedo repeat last AI command in order to re-try
or get an alternative completion.
CONFIGURATION *vim-ai-config*
To customize the default configuration, initialize the config variable with
a selection of options: >
let g:vim_ai_chat = {
\ "options": {
\ "model": "gpt-4",
\ "temperature": 0.2,
\ },
\}
KEY BINDINGS
Examples how configure key bindins and customize commands: >
" complete text on the current line or in visual selection
nnoremap <leader>a :AI<CR>
xnoremap <leader>a :AI<CR>
" edit text with custom context
xnoremap <leader>s :AIEdit fix grammar and spelling<CR>
nnoremap <leader>s :AIEdit fix grammar and spelling<CR>
" trigger chat
xnoremap <leader>c :AIChat<CR>
nnoremap <leader>c :AIChat<CR>
" redo last AI command
nnoremap <leader>r :AIRedo<CR>
" command with custom context (vim-ai functions: AIRun, AIEditRun, AIChatRun)
command! -range -nargs=? AICode <line1>,<line2>call AIRun(<range>, "Programming syntax is " . &filetype . ", " . <f-args>)
ABOUT *vim-ai-about*
Contributions are welcome on GitHub:
https://github.com/madox2/vim-ai
|