{"id":13675315,"url":"https://github.com/jayli/nvim-ai-coding","last_synced_at":"2025-10-23T19:57:36.114Z","repository":{"id":177898291,"uuid":"661073135","full_name":"jayli/nvim-ai-coding","owner":"jayli","description":"nvim ai coding plugin","archived":false,"fork":false,"pushed_at":"2024-01-12T16:38:11.000Z","size":81,"stargazers_count":17,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T11:50:37.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jayli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-07-01T17:48:11.000Z","updated_at":"2024-09-24T02:36:42.000Z","dependencies_parsed_at":"2024-01-12T04:23:52.056Z","dependency_job_id":"e1e69433-ea1b-4755-981f-0d095a5a89f4","html_url":"https://github.com/jayli/nvim-ai-coding","commit_stats":null,"previous_names":["jayli/nvim-ai-coding"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jayli/nvim-ai-coding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayli%2Fnvim-ai-coding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayli%2Fnvim-ai-coding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayli%2Fnvim-ai-coding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayli%2Fnvim-ai-coding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jayli","download_url":"https://codeload.github.com/jayli/nvim-ai-coding/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayli%2Fnvim-ai-coding/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280684034,"owners_count":26372971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T12:00:37.691Z","updated_at":"2025-10-23T19:57:36.099Z","avatar_url":"https://github.com/jayli.png","language":"Vim Script","funding_links":[],"categories":["Code writing and editing"],"sub_categories":[],"readme":"# ![nvim-ai-coding](https://github.com/jayli/nvim-ai-coding/assets/188244/88a28ce3-3240-4793-9637-ef046eaf269a)\n\n基于 chatgpt 写代码的 nvim 插件\n\nhttps://github.com/jayli/nvim-ai-coding/assets/188244/337f0f5c-78b5-4ea1-a276-2868b12562f7\n\n## 一）安装：\n\n### 1. 安装插件\n\n基于 vim-plug 安装， 在 `~/.vimrc` 中添加：\n\n```vim\nPlug 'jayli/nvim-ai-coding'\n```\n\n然后执行`:PlugInstall`\n\n基于 Packer.nvim 安装，在`init.lua`中添加：\n\n```lua\nuse { 'jayli/nvim-ai-coding' }\n```\n\n然后执行 `:PackerInstall`\n\n### 2. 安装 python 依赖\n\n本地 python 3.9 及以上版本，打开命令行执行\n\n```shell\npip install requests langchain openai\n```\n\n或者在插件跟目录下执行:\n\n```shell\npip install -r requirements.txt\n```\n\n### 3. 配置 API 类型和 api key\n\n默认支持四类 API，根据你的需要四选一：\n\n- OpenAI\n- APISpace\n- API2D\n- 自定义 API\n\n**1) OpenAI API key：**\n\n```vim\nlet g:nvim_ai_llm = 'openai'\nlet g:nvim_ai_apikey = 'xxxx'\n```\n\n如果已经配置环境变量`OPENAI_API_KEY`，则可以不用配置`g:nvim_ai_apikey`。\n\n**2) APISpace API：**\n\n```vim\nlet g:nvim_ai_llm = \"apispace\"\nlet g:nvim_ai_apikey = \"xxx\"\n```\n\n**3) API2D**\n\n```vim\nlet g:nvim_ai_llm = 'api2d'\nlet g:nvim_ai_apikey = 'xxx'\n\n\" 大模型配置（可选）\nlet g:nvim_ai_model = \"gpt-4-1106-preview\"\n```\n\nAPI2D 默认支持流式输出，若不想流式输出，配置`g:nvim_ai_stream = 0`。\n\n`g:nvim_ai_model`如果不配置则默认为`gpt-3.5-turbo-0613`，参考值可以配置`gpt-3.5-turbo`或者`gpt-4`等（推荐`gpt-4-1106-preview`）。\n\n**4) 自定义 API：**\n\n```vim\nlet g:nvim_ai_llm = 'custom'\nlet g:nvim_ai_custom_api = 'http://127.0.0.1:8000'\n```\n\n确保自定义接口符合如下格式：接口提交格式 POST：\n\n```json\n{\"prompt\": \"你是基于什么大模型回答问题\", \"history\": []}\n```\n\n接口返回格式：\n\n```json\n{\"response\": \"我是基于gpt4来回答你的问题。\"}\n```\n\n### 4. 更多配置\n\n如果希望绑定其他快捷键，可以重新绑定：\n\n```vim\n\" 默认用 co 唤醒 prompt 输入窗，你可以将 co 改成其他的快捷键\nnmap co \u003cPlug\u003eAICoding\nxmap co \u003cPlug\u003eAICoding\n```\n\n## 二）使用\n\n- 生成模式：Normal 模式下 `co` 唤起输入窗，回车后发送问题并返回结果，`\u003cESC\u003e` 关闭输入窗。\n- 修改模式：选中一段代码，`co` 唤起输入窗，输入指令后，则将针对你选中的代码根据你的指令进行返回。\n\n插件内置了一个简单的 prompt 样板，如果你要新增 prompt，插件可以模糊匹配出你常用的 prompt，这样配置：\n\n```\nlet g:nvim_ai_prompt = [\"/file/path/to/your/prompt.txt\", \"/another/prompt.txt\"]\n```\n\n也可以直接给一个字符串：\n\n```\nlet g:nvim_ai_prompt = \"/file/path/to/your/prompt.txt\"\n```\n\n如果不想加载默认的 prompt 来避免干扰，你可以这样关掉：\n\n```\nlet g:nvim_ai_default_prompt = 0\n```\n\n插件会默认自动记录你的 prompt 历史，可以配置`g:nvim_ai_history_prompt = 0`来关闭历史记录。prompt 历史位于：\n\n- Linux/MacOS：`$HOME/.local/share/nvim/nvim-ai-coding/history.txt`\n- Windows：`$HOME/AppData/Local/nvim/nvim-ai-coding/history.txt`\n\n## 三）LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayli%2Fnvim-ai-coding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjayli%2Fnvim-ai-coding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayli%2Fnvim-ai-coding/lists"}