This project is a fork of vim-ai by madox2. I would like to express my gratitude to the original author for their work.
- Replaced Python code with TypeScript.
- Integrated with coc.nvim for async AI features.
- Ensure your vim is newer than 9 and node is newer than 18:
node --version
, hint for miserable CentOS users: Node.js unofficial-builds project - Install
coc.nvim
. Checkout Install coc.nvim for more infomation. - Use command
:CocInstall https://github.com/Kuro96/coc-ai
in your vim
See roles-example.toml
.
Make a copy of your own and specify path to it with coc-ai.global.rolesConfigPath
.
Available Options, all options are optional:
[<your role name>]
prompt = "<extra prompt which will be add to user prompt>"
[<your role name>.options]
model = "<model name>"
endpointUrl = "<protocol>://<hostname>/v1/chat/completions"
requiresAuth = true # <true/false>
tokenPath = "<path to your token file>"
proxy = "<protocol>://<ip>:<port>"
maxTokens = 4096 # <max token num>
temperature = 0.6 # <temperature>
initialPrompt = "<overrides `initialPrompt` in coc-settings>"
[<your role name>.options-chat]
# same as options, overrides for `AIChat` command
[<your role name>.options-complete]
# same as options, overrides for `AI` command
[<your role name>.options-edit]
# same as options, overrides for `AIEdit` command
Same as role options, but ONLY available with AIChat
command.
Put it on top of ai chat window, or simply modify after one conversation
with coc-ai.chat.populatesOptions
set to true
.
coc-settings.json
, see docs
of coc.nvim
for more info. You can edit it by command :CocConfig
.
Also you can refer to my example below:
{
"coc-ai.global.model": "deepseek-chat",
"coc-ai.global.endpointUrl": "https://api.deepseek.com/v1/chat/completions",
"coc-ai.global.requiresAuth": true,
"coc-ai.global.tokenPath": "~/.vim/token",
"coc-ai.global.rolesConfigPath": "~/.vim/vimrc.d/coc-ai-roles.toml",
"coc-ai.chat.autoScroll": true,
"coc-ai.chat.scratchBufferKeepOpen": false,
"coc-ai.chat.populatesOptions": true,
"coc-ai.chat.preserveFocus": true,
"coc-ai.chat.openChatCommand": "preset_right",
}
role options > chat options > Coc options
- AIChat:
:[%]['<,'>]AIC[hat] [/<role>] [<prompt>]
- AIEdit:
:[%]['<,'>]AIE[dit] [/<role>] [<prompt>]
- AIComplete:
:[%]['<,'>]AI [/<role>] [<prompt>]
- AIStop:
:AIS[top]
- AIBack(resume hidden chat window if
scratchBufferKeepOpen
set totrue
)::AIB[ack]
NOTE:
- any characters inside
[]
is optional :%
equal to:1,$
, checkout:help :%
, as well as:help '<
:help '>
/role
MUST precedeprompt
/role
can be specified multiple times, and the latter configuration will override the former.
:AIC hello world
:AIC /r1 who are you?
:%AIC /gpt-4o-mini /explain 用中文回答
- proxy for api request
- option for chat whether keep track with cursor
- implement ai complete
- implement ai edit
- support
CocInstall
- README
- auto attach with
.aichat
files - maybe auto-complete?
- AI abstraction for chats?
MIT
This extension is built with create-coc-extension