{"id":13646195,"url":"https://github.com/archibate/nvim-gpt","last_synced_at":"2025-08-02T11:32:56.342Z","repository":{"id":152916877,"uuid":"624674296","full_name":"archibate/nvim-gpt","owner":"archibate","description":"Integrated ChatGPT + Bing AI in NeoVim just for neo-pioneers like you :)","archived":false,"fork":false,"pushed_at":"2023-09-27T17:10:56.000Z","size":106,"stargazers_count":39,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-06T20:13:50.693Z","etag":null,"topics":["bingai","chatgpt","neovim","nvim-plugin","pynvim","rplugin","vim"],"latest_commit_sha":null,"homepage":"","language":"Python","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/archibate.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}},"created_at":"2023-04-07T02:01:32.000Z","updated_at":"2025-03-08T00:38:43.000Z","dependencies_parsed_at":"2023-09-27T22:52:56.426Z","dependency_job_id":null,"html_url":"https://github.com/archibate/nvim-gpt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/archibate/nvim-gpt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archibate%2Fnvim-gpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archibate%2Fnvim-gpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archibate%2Fnvim-gpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archibate%2Fnvim-gpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/archibate","download_url":"https://codeload.github.com/archibate/nvim-gpt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archibate%2Fnvim-gpt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268378965,"owners_count":24240907,"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-08-02T02:00:12.353Z","response_time":74,"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":["bingai","chatgpt","neovim","nvim-plugin","pynvim","rplugin","vim"],"created_at":"2024-08-02T01:02:50.321Z","updated_at":"2025-08-02T11:32:56.314Z","avatar_url":"https://github.com/archibate.png","language":"Python","funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# nvim-gpt\n\nIntegrated **ChatGPT** and **Bing AI** in NeoVim just for neo-pioneers like you 😇\n\n## 🤩 Pro tips\n\nYou may use `:GPTOpen` to open the GPT window, as well as `:GPTClose` and `:GPTToggle`. In the GPT window press `i` to start input question, but there are more efficient ways to submit questions and code to GPT.\n\n1. In normal mode:\n\n- Press `\u003cCR\u003e` or `:GPT \u003cquestion\u003e` to enter GPT prompt, input your question, and you get the answer in the pop-up GPT window on the right, automatically started in insert mode.\n- Press `g\u003cCR\u003e` or `:GPTWrite \u003cquestion\u003e` to enter GPT prompt, input your requiement description for code (e.g. write a quick sort). The current filetype will be automatically appended for you (e.g. write a quick sort, in cpp), and you get the code in the pop-up GPT window. And after GPT completes their answer you may press 'a' to insert the code directly to where you pressed `g\u003cCR\u003e`.\n\n2. In visual mode:\n\n- Press `\u003cCR\u003e` or `:GPTCode \u003cquestion\u003e` to enter GPT prompt, input the question you want to ask or action you want to do on the code. The code will be appended to the question, and you will get the output code from GPT in the pop-up GPT window.\n\n3. Utilize the cool vim range expressions:\n\n- Try `:%GPTCode` for sending the whole file to GPT.\n- Try `:.GPTCode` for sending only the current line to GPT.\n- Try `:1,.GPTCode` for sending from first line to current line to GPT.\n- Try `:.,$GPTCode` for sending from current line to last line to GPT.\n- Try `:-5,+4GPTCode` for sending from the previous 5 lines and the next 4 lines to GPT.\n- Try `:'\u003c,'\u003eGPTCode` for sending the selected (visual mode) lines to GPT.\n\n4. In the GPT input prompt:\n\n- You may type 'How to fix this error?' to describe the problem for GPT, press `\u003cCR\u003e` to submit the question.\n- But we've already got some nice templates for you, you may type `@\u003cCR\u003e` in either insert mode or normal mode to start looking up templates (thanks to [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)). Now you may type `fixerr`, and find `How to fix this error?` in the HUD, press `\u003cCR\u003e` and it will be automatically inserted to your question buffer.\n- There is also a useful template `Please wrap the final answer with triple quotes`, which not only gives us a better syntax highlighting for code, but also make it easier to seperate the real answer from GPT's descriptive text like `Sure` or `Here is the result:`.\n- See [keymaps.py](rplugin/python3/py_nvim_gpt/keymaps.py) for a complete list of all templates provided by default, you may override the templates in the setup option `question_templates = ...`.\n- If you want to edit multi-line questions, simply press `\u003cEsc\u003e` then `i` to enter insert mode again. Now pressing `\u003cCR\u003e` in insert mode won't trigger submit anymore, and you may use `\u003cCR\u003e` or `o` in normal mode to compose multi-line questions. After finished editing the question, press `\u003cCR\u003e` in normal mode to submit. The question buffer is remained when you use `r` to regenerate answer from GPT.\n\n5. In the GPT window:\n\n- Suppose you just got the code generated by GPT in the GPT window, now press `a` to accept their change, and apply it to your previous visual selected code lines (simply replace it).\n- Pressing `a` will only paste the code into your file, excluding the descriptive texts, when a triple-quoted \\`\\`\\` code block is found.\n- If you dislike the current answer, you may press `r` to re-edit the question (if needed), then press `\u003cCR\u003e` again let GPT to regenerate a different solution.\n- Press `d` to delete all memory of this GPT session, i.e. reset.\n- Press `s` to stop GPT from generating the complete answer.\n- Press `q` or `\u003cEsc\u003e` to close the GPT window and back to where you're editing.\n- Press `i` to follow up with a new question (equivalent to `:GPT`).\n\n## 🌈 Multi-backend support\n\nYou may use `:GPTModel \u003cmodel_name\u003e` to switch to another model, e.g. `:GPTModel creative` to switch to the Bing AI - 'creative'. The default model is `gpt-3.5-turbo`, which can be tweaked in setup options, see below.\n\nIf you have [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim), use `:Telescope nvim-gpt gpt_model` to show a list of all GPT models to select from.\n\nCurrently supported backends are: `gpt-3.5-turbo`, `gpt-4`, `gpt-4-32k`, `creative`, `balanced`, `percise`, `google-search`.\n\n## 🤔 Install\n\nIt's suggested to use [packer.nvim](https://github.com/wbthomason/packer.nvim) to manage NeoVim plugins, this plugin for example:\n\n```lua\nuse({\n    'archibate/nvim-gpt',\n    -- optional for supporting ':Telescope nvim-gpt gpt_model/gpt_history/gpt_template' commands\n    requires = { 'nvim-telescope/telescope.nvim' },\n    config = function()\n        require'nvim-gpt'.setup {\n            model = 'gpt-3.5-turbo',\n            window_width = 45,\n            -- see more setup options in section 'Setup options' below\n        }\n    end,\n})\n```\n\nAfter adding above code to `init.lua`, restart nvim and run `:PackerInstall` and `:PackerCompile`.\n\nThen try run `:GPTOpen` command and if everything working fine the GPT window should shows up.\n\n\u003e If not, try `:UpdateRemotePlugins`.\n\n\u003e Make sure you have Python3 and ran `python3 -m pip install neovim`\n\n### 🤖 For ChatGPT users\n\n[openai-python](https://github.com/openai/openai-python) is required for using the ChatGPT backend.\n\n```bash\npip install openai\n```\n\n1. Obtain an API key from OpenAI: https://platform.openai.com/account/api-keys\n\n2. Add this to your `~/.bashrc`:\n\n```bash\nexport OPENAI_API_KEY=sk-**********  # replace this with your API key\n```\n\n3. and then restart your shell, enter nvim and choose `gpt-3.5-turbo` or `gpt-4` as model, which is default.\n\n### 👻 For Bing AI users\n\n[EdgeGPT](https://github.com/acheong08/EdgeGPT) is required for using the Bing AI backend.\n\n```bash\npip install EdgeGPT\n```\n\n1. Obtain the cookies JSON via [Cookie Editor](https://microsoftedge.microsoft.com/addons/detail/cookieeditor/neaplmfkghagebokkhpjpoebhdledlfi) plugin from the [Bing site](https://bing.com/chat).\n\n2. Click the 'Export' button on the Cookie editor to dump all the cookies as JSON, then paste all these cookies into a file `~/.bing-cookies.json`.\n\n\u003e See https://github.com/acheong08/EdgeGPT#getting-authentication-required for more details.\n\n3. Enter nvim and `:GPTModel balanced`. For setting Bing AI as default, add `model = 'balanced'` to setup options. You may also use `creative` or `percise` instead.\n\n### 🤡 For Google users\n\n[googlesearch-python](https://pypi.org/project/googlesearch-python) is required for using the Google search backend.\n\n```bash\npip install googlesearch-python\n```\n\nThen enter nvim and `:GPTModel googlesearch-python`. Now search current word with `gy\u003cCR\u003e`, current line with `gs\u003cCR\u003e`.\n\n## ⌨️ Keymaps\n\nThere are keymaps applied **by default** when loading this plugin. See [nvim-gpt.lua](lua/nvim-gpt.lua) and [keymaps.py](rplugin/python3/py_nvim_gpt/keymaps.py):\n\n```vim\nnnoremap \u003csilent\u003e \u003cCR\u003e \u003cCmd\u003eGPT\u003cCR\u003e\nvnoremap \u003csilent\u003e \u003cCR\u003e \u003cCmd\u003eGPTCode\u003cCR\u003e\nnnoremap \u003csilent\u003e g\u003cCR\u003e \u003cCmd\u003eGPTWrite\u003cCR\u003e\nnnoremap \u003csilent\u003e @\u003cCR\u003e \u003cCmd\u003eTelescope nvim-gpt gpt_template initial_mode=insert\u003cCR\u003e\nnnoremap \u003csilent\u003e g@\u003cCR\u003e \u003cCmd\u003eTelescope nvim-gpt gpt_history\u003cCR\u003e\nvnoremap \u003csilent\u003e @\u003cCR\u003e \u003cCmd\u003eGPTCode\u003cCR\u003e\u003cCmd\u003eTelescope nvim-gpt gpt_template initial_mode=insert\u003cCR\u003e\nvnoremap \u003csilent\u003e g@\u003cCR\u003e \u003cCmd\u003eGPTCode\u003cCR\u003e\u003cCmd\u003eTelescope nvim-gpt gpt_history\u003cCR\u003e\nnnoremap \u003csilent\u003e gs\u003cCR\u003e \u003cCmd\u003eexec \":GPT \" . getline('.')\u003cCR\u003e\nnnoremap \u003csilent\u003e gy\u003cCR\u003e \u003cCmd\u003eexec \":GPT \" . expand('\u003ccword\u003e')\u003cCR\u003e\nnnoremap \u003csilent\u003e gu\u003cCR\u003e \u003cCmd\u003e%GPTCode\u003cCR\u003e\nnnoremap \u003csilent\u003e gsm\u003cCR\u003e \u003cCmd\u003eTelescope nvim-gpt gpt_model\u003cCR\u003e\n```\n\nCan be disabled by `no_default_keymaps = true` option in setup.\n\n### 😎 GPT window keymaps\n\nApart from universal keymaps above, inside the GPT window, which is not modifiable, also have their own keymaps:\n\n```vim\n\" (i)nput (a)ccept (c)opy (r)egenerate (d)iscard e(x)ecute (s)top (q)uit\nnnoremap \u003cbuffer\u003e\u003csilent\u003e i \u003cCmd\u003eGPT\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e a \u003cCmd\u003eGPTAccept\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e A \u003cCmd\u003eGPTAccept!\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e c \u003cCmd\u003eGPTYank\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003cnowait\u003e\u003csilent\u003e C \u003cCmd\u003eGPTYank!\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003cnowait\u003e\u003csilent\u003e r \u003cCmd\u003eGPTRegenerate!\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e dd \u003cCmd\u003eGPTDiscard\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e x \u003cCmd\u003eGPTExecute\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e s \u003cCmd\u003eGPTStop\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e q \u003cCmd\u003ewincmd q\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e \u003cEsc\u003e \u003cCmd\u003ewincmd q\u003cCR\u003e\n```\n\n### 😍 Question editing buffer keymaps\n\n```vim\nnnoremap \u003cbuffer\u003e\u003csilent\u003e \u003cCR\u003e \u003cCmd\u003eGPTQuestion\u003cCR\u003e\nvnoremap \u003cbuffer\u003e\u003csilent\u003e \u003cCR\u003e \u003cCmd\u003e\u003cC-u\u003eGPTQuestion\u003cCR\u003e\ninoremap \u003cbuffer\u003e\u003csilent\u003e @\u003cCR\u003e \u003cCmd\u003eTelescope nvim-gpt gpt_template initial_mode=insert\u003cCR\u003e\ninoremap \u003cbuffer\u003e\u003csilent\u003e g\u003cCR\u003e \u003cCmd\u003eTelescope nvim-gpt gpt_history\u003cCR\u003e\nsnoremap \u003cbuffer\u003e\u003csilent\u003e @\u003cCR\u003e \u003cCmd\u003eTelescope nvim-gpt gpt_template initial_mode=insert\u003cCR\u003e\nsnoremap \u003cbuffer\u003e\u003csilent\u003e g\u003cCR\u003e \u003cCmd\u003eTelescope nvim-gpt gpt_history\u003cCR\u003e\ninoremap \u003cexpr\u003e\u003cbuffer\u003e\u003csilent\u003e \u003cCR\u003e (!exists('b:_no_enter_submit') ? '\u003cEsc\u003e\u003cCmd\u003eGPTQuestion\u003cCR\u003e' : '\u003cCR\u003e')\nsnoremap \u003cexpr\u003e\u003cbuffer\u003e\u003csilent\u003e \u003cCR\u003e (!exists('b:_no_enter_submit') ? '\u003cEsc\u003e\u003cCmd\u003eGPTQuestion\u003cCR\u003e' : '\u003cCR\u003e')\ninoremap \u003cbuffer\u003e\u003csilent\u003e \u003cEsc\u003e \u003cEsc\u003e\u003cCmd\u003elet b:_no_enter_submit = 1\u003cCR\u003e\nsnoremap \u003cbuffer\u003e\u003csilent\u003e \u003cEsc\u003e \u003cEsc\u003e\u003cCmd\u003elet b:_no_enter_submit = 1\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e q \u003cCmd\u003ewincmd q\u003cCR\u003e\nnnoremap \u003cbuffer\u003e\u003csilent\u003e \u003cEsc\u003e \u003cCmd\u003ewincmd q\u003cCR\u003e\n```\n\n## 🧐 All setup options\n\n```lua\nrequire'nvim-gpt'.setup {\n    -- which backend to use: 'gpt-3.5-turbo', 'gpt-4', 'gpt-4-32k', 'creative', 'balanced', 'percise', 'google-search'\n    model = 'gpt-3.5-turbo',\n    -- may provide specific parameters like temperature depends on models\n    params = {\n        ['gpt-3.5-turbo'] = {\n            -- see https://platform.openai.com/docs/api-reference/chat/create\n            temperature = 0.85,\n            top_p = 1,\n            n = 1,\n            presence_penalty = 0,\n            frequency_penalty = 0,\n        },\n        ['gpt-4'] = {\n            -- same as above\n        },\n        ['gpt-4-32k'] = {\n            -- same as above\n        },\n        ['google-search'] = {\n            -- see https://pypi.org/project/googlesearch-python\n            num_results = 10,\n            sleep_interval = 0,\n            timeout = 5,\n            lang = 'en',\n            format = '# {title}\\n{url}\\n\\n{desc}',\n        },\n    },\n    -- '|/_\\\\' = rotating loading symbol, '_ ' = blinking on and off, '' = disable\n    cursors = '|/_\\\\',\n    -- this is how we quote code when :'\u003c,'\u003eGPTCode\n    code_quote = '{question}\\n```{filetype}\\n{code}\\n```',\n    -- this is how we quote language type when :GPTWrite\n    in_language = '{question}\\n(in {filetype})',\n    -- title indicating human question in GPT window\n    question_title = '\\n🙂:',\n    -- title indicating bot answer in GPT window\n    answer_title = '\\n🤖:',\n    -- marker use when human requests to regenerate\n    regenerate_title = '🔄',\n    -- whether to show bot's welcome messages on start up: 'fancy', '🤖 {}', 'none'\n    welcome_messages = '🤖 {}',\n    -- GPT window width\n    window_width = 45,\n    -- GPT window specific options\n    window_options = {\n        wrap = true,\n        list = false,\n        cursorline = true,\n        number = false,\n        relativenumber = false,\n    },\n    -- whether we lock to last line when answer: none, last-char, last-line, force\n    lock_last_line = 'force',\n    -- GPT window update interval (ms) when streaming the answer\n    update_interval = 180,\n    -- automatically add default keymaps (see 'Keymaps' section below)\n    no_default_keymaps = false,\n    -- preset templates, can be used like @p or @plain in :GPT or :GPTCode\n    question_templates = [[\nNote that you shall only output the plain answer, with no additional text like 'Sure' or 'Here is the result'.\nPlease wrap the final answer with triple quotes like ```answer```.\nThe answer is wrong, please try again.\nWrite a test for this code.\nWrite an documentation or API reference for this code.\nCould you find any possible BUGs in this code?\nWrite a benchmark for this code. You may want to use the Google Benchmark as framework.\nRewrite to simplify this.\nEdit the code to fix the problem.\nHow to fix this error?\nExplain the purpose of this code, step by step.\nRename the variable and function names to make them more readable.\nRewrite to make this code more readable and maintainable.\nThis line is too long and complex. Could you split it for readability?\nPlease reduce duplication by following the Don't Repeat Yourself principle.\nComplete the missing part of code with given context.\nImplement the function based on its calling signature.\nHere is a markdown file that have several links in the format [name](link), please fill the links according to given name. You may want to search the web if you are not sure about the link.\nMake this expression longer and fullfilling.\nLet's think step by step.\nCould you verify this?\nYou may want to search the web.\nSince the output length is limited. Please omit the unchanged part with ellipses. Only output the changed or newly-added part.\nPlease provide multiple different versions of answer for reference.\nFix possible grammar issues or typos in my writing.\nRewrite with better choices of words.\nTranslate from Chinese to English, or English to Chinese.\n]],\n}\n```\n\nFound bugs or any suggestions? Please let me know by opening a [GitHub issue](https://github.com/archibate/nvim-gpt/issues/new), I'm glad to help 😘\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchibate%2Fnvim-gpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchibate%2Fnvim-gpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchibate%2Fnvim-gpt/lists"}