From aca9d6adc198ef7f387c101e64acde06128d0417 Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Sun, 4 Feb 2024 17:33:48 +0800 Subject: [PATCH 01/68] chore: rename to tips --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71812b99..f8beabaf 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ For further reference, you can view @jellydn's [configuration](https://github.co [![In-place Demo](https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif)](https://gyazo.com/4a5badaa109cd483c1fc23d296325cb0) -## Receipts +## Tips ### Debugging with `:messages` and `:CopilotChatDebugInfo` From 405598454408bd8998851a7bfcf39543b91c6d1c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 4 Feb 2024 09:34:09 +0000 Subject: [PATCH 02/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 1ff3f1bd..c709e515 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -7,7 +7,7 @@ Table of Contents *CopilotChat-table-of-contents* - Authentication |CopilotChat-copilot-chat-for-neovim-authentication| - Installation |CopilotChat-copilot-chat-for-neovim-installation| - Usage |CopilotChat-copilot-chat-for-neovim-usage| - - Receipts |CopilotChat-copilot-chat-for-neovim-receipts| + - Tips |CopilotChat-copilot-chat-for-neovim-tips| - Roadmap |CopilotChat-copilot-chat-for-neovim-roadmap| - Development |CopilotChat-copilot-chat-for-neovim-development| - Contributors ✨ |CopilotChat-copilot-chat-for-neovim-contributors-✨| @@ -199,7 +199,7 @@ IN-PLACE CHAT POPUP ~ -RECEIPTS *CopilotChat-copilot-chat-for-neovim-receipts* +TIPS *CopilotChat-copilot-chat-for-neovim-tips* DEBUGGING WITH :MESSAGES AND :COPILOTCHATDEBUGINFO ~ From d64028b893a6be4e6ed029b530ef620a08cbd979 Mon Sep 17 00:00:00 2001 From: kristofka Date: Sun, 4 Feb 2024 15:24:29 +0100 Subject: [PATCH 03/68] Fixes #56 issue when foldmethod is not manual (#57) See issue #56 --- rplugin/python3/handlers/chat_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index 75f1a3d7..679ae9f3 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -167,6 +167,7 @@ def _add_folds( system_prompt_height: int, winnr: int, ): + self.nvim.command("set foldmethod=manual") system_fold_start = last_row_before + 2 system_fold_end = system_fold_start + system_prompt_height + 3 main_command = f"{system_fold_start}, {system_fold_end} fold | normal! Gzz" From cace00fe5fd365c45125815ac0b8b4e0b769a13e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:24:49 +0800 Subject: [PATCH 04/68] docs: add kristofka as a contributor for code (#58) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 39 ++++++++++++++++++++++++++++++++------- README.md | 5 ++--- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 0a5effab..bc6c1a5a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,5 +1,7 @@ { - "files": ["README.md"], + "files": [ + "README.md" + ], "imageSize": 100, "commit": false, "commitType": "docs", @@ -10,42 +12,65 @@ "name": "gptlang", "avatar_url": "https://avatars.githubusercontent.com/u/121417512?v=4", "profile": "https://github.com/gptlang", - "contributions": ["code", "doc"] + "contributions": [ + "code", + "doc" + ] }, { "login": "jellydn", "name": "Dung Duc Huynh (Kaka)", "avatar_url": "https://avatars.githubusercontent.com/u/870029?v=4", "profile": "https://productsway.com/", - "contributions": ["code", "doc"] + "contributions": [ + "code", + "doc" + ] }, { "login": "qoobes", "name": "Ahmed Haracic", "avatar_url": "https://avatars.githubusercontent.com/u/58834655?v=4", "profile": "https://qoobes.dev", - "contributions": ["code"] + "contributions": [ + "code" + ] }, { "login": "ziontee113", "name": "Trí Thiện Nguyễn", "avatar_url": "https://avatars.githubusercontent.com/u/102876811?v=4", "profile": "https://youtube.com/@ziontee113", - "contributions": ["code"] + "contributions": [ + "code" + ] }, { "login": "Cassius0924", "name": "He Zhizhou", "avatar_url": "https://avatars.githubusercontent.com/u/62874592?v=4", "profile": "https://github.com/Cassius0924", - "contributions": ["code"] + "contributions": [ + "code" + ] }, { "login": "rguruprakash", "name": "Guruprakash Rajakkannu", "avatar_url": "https://avatars.githubusercontent.com/u/9963717?v=4", "profile": "https://www.linkedin.com/in/guruprakashrajakkannu/", - "contributions": ["code"] + "contributions": [ + "code" + ] + }, + { + "login": "kristofka", + "name": "kristofka", + "avatar_url": "https://avatars.githubusercontent.com/u/140354?v=4", + "profile": "https://github.com/kristofka", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index f8beabaf..c35d79eb 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ # Copilot Chat for Neovim - -[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors-) - +[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-) > [!NOTE] @@ -284,6 +282,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Trí Thiện Nguyễn
Trí Thiện Nguyễn

💻 He Zhizhou
He Zhizhou

💻 Guruprakash Rajakkannu
Guruprakash Rajakkannu

💻 + kristofka
kristofka

💻 From 6ff5b0a2fc4d2399949506f5d32af863498b28db Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Sun, 4 Feb 2024 18:45:23 +0000 Subject: [PATCH 05/68] merge jellydn fork --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c35d79eb..0f30fdf7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-) +> [!NOTE] +> You might want to take a look at [this fork](https://github.com/jellydn/CopilotChat.nvim) which is more well maintained & is more configurable. I personally use it now as well. + > [!NOTE] > A new command, `CopilotChatInPlace` has been introduced. It functions like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart Neovim before starting a chat with Copilot. To stay updated on our roadmap, please join our [Discord](https://discord.gg/vy6hJsTWaZ) community. From df5d60a200be4afb177f49df9b955ffdbbed0dc4 Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Sun, 4 Feb 2024 18:45:53 +0000 Subject: [PATCH 06/68] remove release workflow --- .github/workflows/release.yml | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 9860c202..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Release -on: - push: - pull_request: - -jobs: - release: - name: release - runs-on: ubuntu-latest - steps: - - uses: google-github-actions/release-please-action@v3 - id: release - with: - release-type: simple - package-name: CopilotChat.nvim - - uses: actions/checkout@v3 - - name: tag stable versions - if: ${{ steps.release.outputs.release_created }} - run: | - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" - git tag -d stable || true - git push origin :stable || true - git tag -a stable -m "Last Stable Release" - git push origin stable From 3b1cfc5e80594fe1ecf0e2616ec933a9f3a7a98f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 4 Feb 2024 18:46:12 +0000 Subject: [PATCH 07/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index c709e515..95c857e4 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -18,6 +18,10 @@ Table of Contents *CopilotChat-table-of-contents* |CopilotChat-| + [!NOTE] You might want to take a look at this fork + which is more well maintained & + is more configurable. I personally use it now as well. + [!NOTE] A new command, `CopilotChatInPlace` has been introduced. It functions like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart Neovim before starting a chat with Copilot. To stay updated on our roadmap, @@ -309,14 +313,14 @@ CONTRIBUTORS ✨ *CopilotChat-copilot-chat-for-neovim-contributors-✨* Thanks goes to these wonderful people (emoji key ): -gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻This project follows the all-contributors +gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻This project follows the all-contributors specification. Contributions of any kind welcome! ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square +1. *All Contributors*: https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square 2. *@jellydn*: 3. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif 4. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif From 55826c1cb915a2be51b57c1eaf29bca5c59cc8ac Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Sun, 4 Feb 2024 19:04:08 +0000 Subject: [PATCH 08/68] put the authentication code back --- .all-contributorsrc | 34 +++++------------- CHANGELOG.md | 45 ++++++++++-------------- README.md | 2 ++ rplugin/python3/handlers/chat_handler.py | 18 +++++++++- 4 files changed, 46 insertions(+), 53 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index bc6c1a5a..4bd80307 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,5 @@ { - "files": [ - "README.md" - ], + "files": ["README.md"], "imageSize": 100, "commit": false, "commitType": "docs", @@ -12,65 +10,49 @@ "name": "gptlang", "avatar_url": "https://avatars.githubusercontent.com/u/121417512?v=4", "profile": "https://github.com/gptlang", - "contributions": [ - "code", - "doc" - ] + "contributions": ["code", "doc"] }, { "login": "jellydn", "name": "Dung Duc Huynh (Kaka)", "avatar_url": "https://avatars.githubusercontent.com/u/870029?v=4", "profile": "https://productsway.com/", - "contributions": [ - "code", - "doc" - ] + "contributions": ["code", "doc"] }, { "login": "qoobes", "name": "Ahmed Haracic", "avatar_url": "https://avatars.githubusercontent.com/u/58834655?v=4", "profile": "https://qoobes.dev", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "ziontee113", "name": "Trí Thiện Nguyễn", "avatar_url": "https://avatars.githubusercontent.com/u/102876811?v=4", "profile": "https://youtube.com/@ziontee113", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "Cassius0924", "name": "He Zhizhou", "avatar_url": "https://avatars.githubusercontent.com/u/62874592?v=4", "profile": "https://github.com/Cassius0924", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "rguruprakash", "name": "Guruprakash Rajakkannu", "avatar_url": "https://avatars.githubusercontent.com/u/9963717?v=4", "profile": "https://www.linkedin.com/in/guruprakashrajakkannu/", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "kristofka", "name": "kristofka", "avatar_url": "https://avatars.githubusercontent.com/u/140354?v=4", "profile": "https://github.com/kristofka", - "contributions": [ - "code" - ] + "contributions": ["code"] } ], "contributorsPerLine": 7, diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c095c00..20d5a900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,56 +2,49 @@ ## [1.2.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-04) - ### Features -* show date time and additional information on end separator ([#53](https://github.com/jellydn/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/jellydn/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) - +- show date time and additional information on end separator ([#53](https://github.com/jellydn/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/jellydn/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) ### Bug Fixes -* handle get remote plugin path on Windows ([0b917f6](https://github.com/jellydn/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) +- handle get remote plugin path on Windows ([0b917f6](https://github.com/jellydn/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) ## [1.1.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.0.0...v1.1.0) (2024-02-04) - ### Features -* add CopilotChatDebugInfo command ([#51](https://github.com/jellydn/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/jellydn/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) +- add CopilotChatDebugInfo command ([#51](https://github.com/jellydn/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/jellydn/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) ## 1.0.0 (2024-02-03) - ### ⚠ BREAKING CHANGES -* drop new buffer mode +- drop new buffer mode ### Features -* add a note for help user to continue the chat ([8a80ee7](https://github.com/jellydn/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) -* add CCExplain command ([640f361](https://github.com/jellydn/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) -* add CCTests command ([b34a78f](https://github.com/jellydn/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) -* add configuration options for wrap and filetype ([b4c6e76](https://github.com/jellydn/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) -* add CopilotChatToggleLayout ([07988b9](https://github.com/jellydn/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) -* add debug flag ([d0dbd4c](https://github.com/jellydn/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) -* add health check ([974f14f](https://github.com/jellydn/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) -* add new keymap to get previous user prompt ([6e7e80f](https://github.com/jellydn/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) -* set filetype to markdown and text wrapping ([9b19d51](https://github.com/jellydn/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) -* show chat in markdown format ([9c14152](https://github.com/jellydn/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) - +- add a note for help user to continue the chat ([8a80ee7](https://github.com/jellydn/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) +- add CCExplain command ([640f361](https://github.com/jellydn/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) +- add CCTests command ([b34a78f](https://github.com/jellydn/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) +- add configuration options for wrap and filetype ([b4c6e76](https://github.com/jellydn/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) +- add CopilotChatToggleLayout ([07988b9](https://github.com/jellydn/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) +- add debug flag ([d0dbd4c](https://github.com/jellydn/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) +- add health check ([974f14f](https://github.com/jellydn/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) +- add new keymap to get previous user prompt ([6e7e80f](https://github.com/jellydn/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) +- set filetype to markdown and text wrapping ([9b19d51](https://github.com/jellydn/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) +- show chat in markdown format ([9c14152](https://github.com/jellydn/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) ### Bug Fixes -* **ci:** generate doc ([6287fd4](https://github.com/jellydn/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) -* Close spinner if the buffer does not exist ([#11](https://github.com/jellydn/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/jellydn/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) -* remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/jellydn/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/jellydn/CopilotChat.nvim/issues/45) - +- **ci:** generate doc ([6287fd4](https://github.com/jellydn/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) +- Close spinner if the buffer does not exist ([#11](https://github.com/jellydn/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/jellydn/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) +- remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/jellydn/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/jellydn/CopilotChat.nvim/issues/45) ### Reverts -* change back to CopilotChat command ([e304f79](https://github.com/jellydn/CopilotChat.nvim/commit/e304f792a5fbba412c2a5a1f717ec7e2ab12e5b0)) - +- change back to CopilotChat command ([e304f79](https://github.com/jellydn/CopilotChat.nvim/commit/e304f792a5fbba412c2a5a1f717ec7e2ab12e5b0)) ### Code Refactoring -* drop new buffer mode ([0a30b7c](https://github.com/jellydn/CopilotChat.nvim/commit/0a30b7cfbd8b52bf8a9e4cd96dcade4995e6eb3a)) +- drop new buffer mode ([0a30b7c](https://github.com/jellydn/CopilotChat.nvim/commit/0a30b7cfbd8b52bf8a9e4cd96dcade4995e6eb3a)) diff --git a/README.md b/README.md index 0f30fdf7..d2d923f2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # Copilot Chat for Neovim + [![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-) + > [!NOTE] diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index 679ae9f3..910e642e 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -1,3 +1,4 @@ +import time from datetime import datetime from typing import Optional, cast @@ -18,7 +19,7 @@ def is_module_installed(name): class ChatHandler: def __init__(self, nvim: MyNvim, buffer: MyBuffer): self.nvim: MyNvim = nvim - self.copilot = None + self.copilot: Copilot = None self.buffer: MyBuffer = buffer # public @@ -186,6 +187,21 @@ def _add_chat_messages( ): if self.copilot is None: self.copilot = Copilot() + if self.copilot.github_token is None: + req = self.copilot.request_auth() + self.nvim.out_write( + f"Please visit {req['verification_uri']} and enter the code {req['user_code']}\n" + ) + current_time = time.time() + wait_until = current_time + req["expires_in"] + while self.copilot.github_token is None: + self.copilot.poll_auth(req["device_code"]) + time.sleep(req["interval"]) + if time.time() > wait_until: + self.nvim.out_write("Timed out waiting for authentication\n") + return + self.nvim.out_write("Successfully authenticated with Copilot\n") + self.copilot.authenticate() for token in self.copilot.ask( system_prompt, prompt, code, language=cast(str, file_type), model=model From 1786aa81e25388cd5bf6437353bed22cd2276e4a Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Sun, 4 Feb 2024 19:05:59 +0000 Subject: [PATCH 09/68] We don't actually have dependencies --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d2d923f2..07047001 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ It will prompt you with instructions on your first start. If you already have `C return { { "jellydn/CopilotChat.nvim", - dependencies = { "zbirenbaum/copilot.lua" }, -- Or { "github/copilot.vim" } opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log From 1877e35422a71381a9a1445ebac52d88d4e10a4b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 4 Feb 2024 19:06:22 +0000 Subject: [PATCH 10/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 95c857e4..89d6c082 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -46,7 +46,6 @@ LAZY.NVIM ~ return { { "jellydn/CopilotChat.nvim", - dependencies = { "zbirenbaum/copilot.lua" }, -- Or { "github/copilot.vim" } opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log From f5df49ac959fbbc71da9af7b0499d3415bd8cba9 Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Sun, 4 Feb 2024 19:47:15 +0000 Subject: [PATCH 11/68] Restore authentication code on first start (#59) * merge jellydn fork * remove release workflow * chore(doc): auto generate docs * put the authentication code back * We don't actually have dependencies * chore(doc): auto generate docs * remove pointer to fork in preparation for PR --------- Co-authored-by: github-actions[bot] --- .all-contributorsrc | 34 +++++------------- .github/workflows/release.yml | 26 -------------- CHANGELOG.md | 45 ++++++++++-------------- README.md | 3 +- doc/CopilotChat.txt | 9 +++-- rplugin/python3/handlers/chat_handler.py | 18 +++++++++- 6 files changed, 52 insertions(+), 83 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.all-contributorsrc b/.all-contributorsrc index bc6c1a5a..4bd80307 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,5 @@ { - "files": [ - "README.md" - ], + "files": ["README.md"], "imageSize": 100, "commit": false, "commitType": "docs", @@ -12,65 +10,49 @@ "name": "gptlang", "avatar_url": "https://avatars.githubusercontent.com/u/121417512?v=4", "profile": "https://github.com/gptlang", - "contributions": [ - "code", - "doc" - ] + "contributions": ["code", "doc"] }, { "login": "jellydn", "name": "Dung Duc Huynh (Kaka)", "avatar_url": "https://avatars.githubusercontent.com/u/870029?v=4", "profile": "https://productsway.com/", - "contributions": [ - "code", - "doc" - ] + "contributions": ["code", "doc"] }, { "login": "qoobes", "name": "Ahmed Haracic", "avatar_url": "https://avatars.githubusercontent.com/u/58834655?v=4", "profile": "https://qoobes.dev", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "ziontee113", "name": "Trí Thiện Nguyễn", "avatar_url": "https://avatars.githubusercontent.com/u/102876811?v=4", "profile": "https://youtube.com/@ziontee113", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "Cassius0924", "name": "He Zhizhou", "avatar_url": "https://avatars.githubusercontent.com/u/62874592?v=4", "profile": "https://github.com/Cassius0924", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "rguruprakash", "name": "Guruprakash Rajakkannu", "avatar_url": "https://avatars.githubusercontent.com/u/9963717?v=4", "profile": "https://www.linkedin.com/in/guruprakashrajakkannu/", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "kristofka", "name": "kristofka", "avatar_url": "https://avatars.githubusercontent.com/u/140354?v=4", "profile": "https://github.com/kristofka", - "contributions": [ - "code" - ] + "contributions": ["code"] } ], "contributorsPerLine": 7, diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 9860c202..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Release -on: - push: - pull_request: - -jobs: - release: - name: release - runs-on: ubuntu-latest - steps: - - uses: google-github-actions/release-please-action@v3 - id: release - with: - release-type: simple - package-name: CopilotChat.nvim - - uses: actions/checkout@v3 - - name: tag stable versions - if: ${{ steps.release.outputs.release_created }} - run: | - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" - git tag -d stable || true - git push origin :stable || true - git tag -a stable -m "Last Stable Release" - git push origin stable diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c095c00..20d5a900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,56 +2,49 @@ ## [1.2.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-04) - ### Features -* show date time and additional information on end separator ([#53](https://github.com/jellydn/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/jellydn/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) - +- show date time and additional information on end separator ([#53](https://github.com/jellydn/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/jellydn/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) ### Bug Fixes -* handle get remote plugin path on Windows ([0b917f6](https://github.com/jellydn/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) +- handle get remote plugin path on Windows ([0b917f6](https://github.com/jellydn/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) ## [1.1.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.0.0...v1.1.0) (2024-02-04) - ### Features -* add CopilotChatDebugInfo command ([#51](https://github.com/jellydn/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/jellydn/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) +- add CopilotChatDebugInfo command ([#51](https://github.com/jellydn/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/jellydn/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) ## 1.0.0 (2024-02-03) - ### ⚠ BREAKING CHANGES -* drop new buffer mode +- drop new buffer mode ### Features -* add a note for help user to continue the chat ([8a80ee7](https://github.com/jellydn/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) -* add CCExplain command ([640f361](https://github.com/jellydn/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) -* add CCTests command ([b34a78f](https://github.com/jellydn/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) -* add configuration options for wrap and filetype ([b4c6e76](https://github.com/jellydn/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) -* add CopilotChatToggleLayout ([07988b9](https://github.com/jellydn/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) -* add debug flag ([d0dbd4c](https://github.com/jellydn/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) -* add health check ([974f14f](https://github.com/jellydn/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) -* add new keymap to get previous user prompt ([6e7e80f](https://github.com/jellydn/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) -* set filetype to markdown and text wrapping ([9b19d51](https://github.com/jellydn/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) -* show chat in markdown format ([9c14152](https://github.com/jellydn/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) - +- add a note for help user to continue the chat ([8a80ee7](https://github.com/jellydn/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) +- add CCExplain command ([640f361](https://github.com/jellydn/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) +- add CCTests command ([b34a78f](https://github.com/jellydn/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) +- add configuration options for wrap and filetype ([b4c6e76](https://github.com/jellydn/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) +- add CopilotChatToggleLayout ([07988b9](https://github.com/jellydn/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) +- add debug flag ([d0dbd4c](https://github.com/jellydn/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) +- add health check ([974f14f](https://github.com/jellydn/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) +- add new keymap to get previous user prompt ([6e7e80f](https://github.com/jellydn/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) +- set filetype to markdown and text wrapping ([9b19d51](https://github.com/jellydn/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) +- show chat in markdown format ([9c14152](https://github.com/jellydn/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) ### Bug Fixes -* **ci:** generate doc ([6287fd4](https://github.com/jellydn/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) -* Close spinner if the buffer does not exist ([#11](https://github.com/jellydn/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/jellydn/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) -* remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/jellydn/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/jellydn/CopilotChat.nvim/issues/45) - +- **ci:** generate doc ([6287fd4](https://github.com/jellydn/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) +- Close spinner if the buffer does not exist ([#11](https://github.com/jellydn/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/jellydn/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) +- remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/jellydn/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/jellydn/CopilotChat.nvim/issues/45) ### Reverts -* change back to CopilotChat command ([e304f79](https://github.com/jellydn/CopilotChat.nvim/commit/e304f792a5fbba412c2a5a1f717ec7e2ab12e5b0)) - +- change back to CopilotChat command ([e304f79](https://github.com/jellydn/CopilotChat.nvim/commit/e304f792a5fbba412c2a5a1f717ec7e2ab12e5b0)) ### Code Refactoring -* drop new buffer mode ([0a30b7c](https://github.com/jellydn/CopilotChat.nvim/commit/0a30b7cfbd8b52bf8a9e4cd96dcade4995e6eb3a)) +- drop new buffer mode ([0a30b7c](https://github.com/jellydn/CopilotChat.nvim/commit/0a30b7cfbd8b52bf8a9e4cd96dcade4995e6eb3a)) diff --git a/README.md b/README.md index c35d79eb..13d4f20e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # Copilot Chat for Neovim + [![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-) + > [!NOTE] @@ -23,7 +25,6 @@ It will prompt you with instructions on your first start. If you already have `C return { { "jellydn/CopilotChat.nvim", - dependencies = { "zbirenbaum/copilot.lua" }, -- Or { "github/copilot.vim" } opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index c709e515..89d6c082 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -18,6 +18,10 @@ Table of Contents *CopilotChat-table-of-contents* |CopilotChat-| + [!NOTE] You might want to take a look at this fork + which is more well maintained & + is more configurable. I personally use it now as well. + [!NOTE] A new command, `CopilotChatInPlace` has been introduced. It functions like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart Neovim before starting a chat with Copilot. To stay updated on our roadmap, @@ -42,7 +46,6 @@ LAZY.NVIM ~ return { { "jellydn/CopilotChat.nvim", - dependencies = { "zbirenbaum/copilot.lua" }, -- Or { "github/copilot.vim" } opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log @@ -309,14 +312,14 @@ CONTRIBUTORS ✨ *CopilotChat-copilot-chat-for-neovim-contributors-✨* Thanks goes to these wonderful people (emoji key ): -gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻This project follows the all-contributors +gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻This project follows the all-contributors specification. Contributions of any kind welcome! ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square +1. *All Contributors*: https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square 2. *@jellydn*: 3. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif 4. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index 679ae9f3..910e642e 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -1,3 +1,4 @@ +import time from datetime import datetime from typing import Optional, cast @@ -18,7 +19,7 @@ def is_module_installed(name): class ChatHandler: def __init__(self, nvim: MyNvim, buffer: MyBuffer): self.nvim: MyNvim = nvim - self.copilot = None + self.copilot: Copilot = None self.buffer: MyBuffer = buffer # public @@ -186,6 +187,21 @@ def _add_chat_messages( ): if self.copilot is None: self.copilot = Copilot() + if self.copilot.github_token is None: + req = self.copilot.request_auth() + self.nvim.out_write( + f"Please visit {req['verification_uri']} and enter the code {req['user_code']}\n" + ) + current_time = time.time() + wait_until = current_time + req["expires_in"] + while self.copilot.github_token is None: + self.copilot.poll_auth(req["device_code"]) + time.sleep(req["interval"]) + if time.time() > wait_until: + self.nvim.out_write("Timed out waiting for authentication\n") + return + self.nvim.out_write("Successfully authenticated with Copilot\n") + self.copilot.authenticate() for token in self.copilot.ask( system_prompt, prompt, code, language=cast(str, file_type), model=model From 7d4cb93e6c591932e5a3b215a5b65d9754bc1a80 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 4 Feb 2024 19:47:35 +0000 Subject: [PATCH 12/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 89d6c082..8043f7df 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -18,10 +18,6 @@ Table of Contents *CopilotChat-table-of-contents* |CopilotChat-| - [!NOTE] You might want to take a look at this fork - which is more well maintained & - is more configurable. I personally use it now as well. - [!NOTE] A new command, `CopilotChatInPlace` has been introduced. It functions like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart Neovim before starting a chat with Copilot. To stay updated on our roadmap, From 81a9d818b1369d41108c46da477e4ea5cec0a525 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Mon, 5 Feb 2024 03:54:40 +0800 Subject: [PATCH 13/68] revert(ci): add release workflow back --- .github/workflows/release.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..6f3d1425 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release +on: + push: + branches: + - release + pull_request: + branches: + - main + - release + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: simple + package-name: CopilotChat.nvim + - uses: actions/checkout@v3 + - name: tag stable versions + if: ${{ steps.release.outputs.release_created }} + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" + git tag -d stable || true + git push origin :stable || true + git tag -a stable -m "Last Stable Release" + git push origin stable From 033406776b3ca084aacdbae18c5f864b52d64ef1 Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Sun, 4 Feb 2024 20:51:49 +0000 Subject: [PATCH 14/68] fix Python3.10 by removing Unpack type infomation --- rplugin/python3/mypynvim/ui_components/popup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rplugin/python3/mypynvim/ui_components/popup.py b/rplugin/python3/mypynvim/ui_components/popup.py index 9040b452..cab2bac9 100644 --- a/rplugin/python3/mypynvim/ui_components/popup.py +++ b/rplugin/python3/mypynvim/ui_components/popup.py @@ -2,7 +2,7 @@ from copy import deepcopy from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Union, Unpack +from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Union if TYPE_CHECKING: from mypynvim.core.nvim import MyNvim @@ -14,7 +14,7 @@ from mypynvim.core.window import MyWindow from .calculator import Calculator -from .types import PaddingKeys, PopUpArgs, PopUpConfiguration, Relative +from .types import PaddingKeys, PopUpConfiguration, Relative @dataclass @@ -33,7 +33,7 @@ def __init__( padding: PaddingKeys = {}, enter: bool = False, opts={}, - **kwargs: Unpack[PopUpArgs], + **kwargs, ): self.nvim: MyNvim = nvim self.calculator: Calculator = Calculator(self.nvim) From 1f57cf457cdc1ca87fc2f9c9db9ef447c0165629 Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:18:26 +0000 Subject: [PATCH 15/68] add option to remove extra information: disable_extra_info --- lua/CopilotChat/init.lua | 1 + rplugin/python3/handlers/chat_handler.py | 32 +++++++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 85510023..a5876373 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -16,6 +16,7 @@ _COPILOT_CHAT_GLOBAL_CONFIG = {} -- - debug: (boolean?) default: false. M.setup = function(options) vim.g.copilot_chat_show_help = options and options.show_help or 'yes' + vim.g.copilot_chat_disable_separators = options and options.disable_extra_info or false local debug = options and options.debug or false _COPILOT_CHAT_GLOBAL_CONFIG.debug = debug diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index 910e642e..3fe7b3d2 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -35,9 +35,9 @@ def chat( disable_end_separator: bool = False, model: str = "gpt-4", ): + no_annoyance = self.nvim.eval("g:copilot_chat_disable_separators") == "yes" if system_prompt is None: system_prompt = self._construct_system_prompt(prompt) - # Start the spinner self.nvim.exec_lua('require("CopilotChat.spinner").show()') @@ -46,7 +46,9 @@ def chat( ) if not disable_start_separator: - self._add_start_separator(system_prompt, prompt, code, filetype, winnr) + self._add_start_separator( + system_prompt, prompt, code, filetype, winnr, no_annoyance + ) self._add_chat_messages(system_prompt, prompt, code, filetype, model) @@ -54,7 +56,7 @@ def chat( self.nvim.exec_lua('require("CopilotChat.spinner").hide()') if not disable_end_separator: - self._add_end_separator(model) + self._add_end_separator(model, no_annoyance) # private @@ -75,14 +77,15 @@ def _add_start_separator( code: str, file_type: str, winnr: int, + no_annoyance: bool = False, ): - if is_module_installed("tiktoken"): + if is_module_installed("tiktoken") and not no_annoyance: self._add_start_separator_with_token_count( system_prompt, prompt, code, file_type, winnr ) else: self._add_regular_start_separator( - system_prompt, prompt, code, file_type, winnr + system_prompt, prompt, code, file_type, winnr, no_annoyance ) def _add_regular_start_separator( @@ -92,15 +95,17 @@ def _add_regular_start_separator( code: str, file_type: str, winnr: int, + no_annoyance: bool = False, ): - if code: + if code and not no_annoyance: code = f"\n \nCODE:\n```{file_type}\n{code}\n```" last_row_before = len(self.buffer.lines()) system_prompt_height = len(system_prompt.split("\n")) code_height = len(code.split("\n")) - start_separator = f"""### User + start_separator = ( + f"""### User SYSTEM PROMPT: ``` @@ -111,8 +116,13 @@ def _add_regular_start_separator( ### Copilot """ + if not no_annoyance + else f"### User\n{prompt}\n\n### Copilot\n\n" + ) self.buffer.append(start_separator.split("\n")) + if no_annoyance: + return self._add_folds(code, code_height, last_row_before, system_prompt_height, winnr) def _add_start_separator_with_token_count( @@ -222,13 +232,17 @@ def _add_chat_messages( token.split("\n"), ) - def _add_end_separator(self, model: str): + def _add_end_separator(self, model: str, no_annoyance: bool = False): current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") model_info = f"\n#### Answer provided by Copilot (Model: `{model}`) on {current_datetime}." additional_instructions = ( "\n> For additional queries, please use the `CopilotChat` command." ) - disclaimer = "\n> Please be aware that the AI's output may not always be accurate. Always cross-verify the output.\n---\n" + disclaimer = "\n> Please be aware that the AI's output may not always be accurate. Always cross-verify the output." end_message = model_info + additional_instructions + disclaimer + + if no_annoyance: + end_message = "\n" + current_datetime + "\n---\n" + self.buffer.append(end_message.split("\n")) From 2b850b8edd220884a264ebbbf6cf1ae17c1663d0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 08:06:43 +0800 Subject: [PATCH 16/68] chore(main): release 1.2.1 (#61) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d5a900..0ccfe4ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.2.1](https://github.com/jellydn/CopilotChat.nvim/compare/v1.2.0...v1.2.1) (2024-02-05) + + +### Reverts + +* **ci:** add release workflow back ([81a9d81](https://github.com/jellydn/CopilotChat.nvim/commit/81a9d818b1369d41108c46da477e4ea5cec0a525)) + ## [1.2.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-04) ### Features From 4694b66538605bd57cec0f9355bab8f36a1f0ccb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 Feb 2024 00:07:01 +0000 Subject: [PATCH 17/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 89d6c082..a9462e8e 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 04 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 05 ============================================================================== Table of Contents *CopilotChat-table-of-contents* From 5c4c22d1bb13d1d927c3301840d2a0699df2b732 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Mon, 5 Feb 2024 10:24:36 +0800 Subject: [PATCH 18/68] refactor!: disable extra info as default --- lua/CopilotChat/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index a5876373..9fe5f325 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -12,11 +12,12 @@ _COPILOT_CHAT_GLOBAL_CONFIG = {} -- Set up the plugin ---@param options (table | nil) -- - show_help: ('yes' | 'no') default: 'yes'. +-- - disable_extra_info: ('yes' | 'no') default: 'yes'. -- - prompts: (table?) default: default_prompts. -- - debug: (boolean?) default: false. M.setup = function(options) vim.g.copilot_chat_show_help = options and options.show_help or 'yes' - vim.g.copilot_chat_disable_separators = options and options.disable_extra_info or false + vim.g.copilot_chat_disable_separators = options and options.disable_extra_info or 'yes' local debug = options and options.debug or false _COPILOT_CHAT_GLOBAL_CONFIG.debug = debug From a5319e508910c4f90ca8fd91f368074eb2a00048 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Mon, 5 Feb 2024 10:24:58 +0800 Subject: [PATCH 19/68] docs: add disable_extra_info flag on readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 07047001..b2e07617 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ return { opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log + disable_extra_info = 'no', -- Disable extra information (e.g: system prompt) in the response. }, build = function() vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.") From 4d596994d1df9e05a8e6715c43aa81b1798e885e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 Feb 2024 02:25:21 +0000 Subject: [PATCH 20/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index a9462e8e..d4e5a880 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -49,6 +49,7 @@ LAZY.NVIM ~ opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log + disable_extra_info = 'no', -- Disable extra information (e.g: system prompt) in the response. }, build = function() vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.") From 0fa28e7f78e6caa062e5c6a19f3713ff0b0ad547 Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:44:06 +0800 Subject: [PATCH 21/68] docs: add same keybinds in both visual and normal mode (#24) * Fix Python 3.10 and add disable_extra_info option (#60) * fix Python3.10 by removing Unpack type infomation * add option to remove extra information: disable_extra_info * chore(main): release 1.2.1 (#61) * chore(doc): auto generate docs * refactor!: disable extra info as default * docs: add disable_extra_info flag on readme * chore(doc): auto generate docs * docs: add PostCyberPunk as a contributor for doc (#63) * chore(doc): auto generate docs * docs: add same keybinds in both visual and normal mode (#62) (#64) Co-authored-by: PostCyberPunk <134976996+PostCyberPunk@users.noreply.github.com> * chore(doc): auto generate docs --------- Co-authored-by: gptlang <121417512+gptlang@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: PostCyberPunk <134976996+PostCyberPunk@users.noreply.github.com> --- .all-contributorsrc | 43 +++++++++++++++++++++++++++++++++++-------- README.md | 37 ++++++++++++++++++++++++++++++++++--- doc/CopilotChat.txt | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 102 insertions(+), 13 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4bd80307..59f826dd 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,5 +1,7 @@ { - "files": ["README.md"], + "files": [ + "README.md" + ], "imageSize": 100, "commit": false, "commitType": "docs", @@ -10,49 +12,74 @@ "name": "gptlang", "avatar_url": "https://avatars.githubusercontent.com/u/121417512?v=4", "profile": "https://github.com/gptlang", - "contributions": ["code", "doc"] + "contributions": [ + "code", + "doc" + ] }, { "login": "jellydn", "name": "Dung Duc Huynh (Kaka)", "avatar_url": "https://avatars.githubusercontent.com/u/870029?v=4", "profile": "https://productsway.com/", - "contributions": ["code", "doc"] + "contributions": [ + "code", + "doc" + ] }, { "login": "qoobes", "name": "Ahmed Haracic", "avatar_url": "https://avatars.githubusercontent.com/u/58834655?v=4", "profile": "https://qoobes.dev", - "contributions": ["code"] + "contributions": [ + "code" + ] }, { "login": "ziontee113", "name": "Trí Thiện Nguyễn", "avatar_url": "https://avatars.githubusercontent.com/u/102876811?v=4", "profile": "https://youtube.com/@ziontee113", - "contributions": ["code"] + "contributions": [ + "code" + ] }, { "login": "Cassius0924", "name": "He Zhizhou", "avatar_url": "https://avatars.githubusercontent.com/u/62874592?v=4", "profile": "https://github.com/Cassius0924", - "contributions": ["code"] + "contributions": [ + "code" + ] }, { "login": "rguruprakash", "name": "Guruprakash Rajakkannu", "avatar_url": "https://avatars.githubusercontent.com/u/9963717?v=4", "profile": "https://www.linkedin.com/in/guruprakashrajakkannu/", - "contributions": ["code"] + "contributions": [ + "code" + ] }, { "login": "kristofka", "name": "kristofka", "avatar_url": "https://avatars.githubusercontent.com/u/140354?v=4", "profile": "https://github.com/kristofka", - "contributions": ["code"] + "contributions": [ + "code" + ] + }, + { + "login": "PostCyberPunk", + "name": "PostCyberPunk", + "avatar_url": "https://avatars.githubusercontent.com/u/134976996?v=4", + "profile": "https://github.com/PostCyberPunk", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index b2e07617..15dc5bb9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ # Copilot Chat for Neovim - -[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-) - +[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-) > [!NOTE] @@ -252,6 +250,36 @@ Follow the example below to create a simple input for CopilotChat. }, ``` +### Add same keybinds in both visual and normal mode + +```lua + { + "jellydn/CopilotChat.nvim", + keys = + function() + local keybinds={ + --add your custom keybinds here + } + -- change prompt and keybinds as per your need + local my_prompts = { + {prompt = "In Neovim.",desc = "Neovim",key = "n"}, + {prompt = "Help with this",desc = "Help",key = "h"}, + {prompt = "Simplify and imporve readablilty",desc = "Simplify",key = "s"}, + {prompt = "Optimize the code to improve perfomance and readablilty.",desc = "Optimize",key = "o"}, + {prompt = "Find possible errors and fix them for me",desc = "Fix",key = "f"}, + {prompt = "Explain in detail",desc = "Explain",key = "e"}, + {prompt = "Write a shell scirpt",desc = "Shell",key = "S"}, + } + -- you can change cc to your desired keybind prefix + for _,v in pairs(my_prompts) do + table.insert(keybinds,{ "cc"..v.key, ":CopilotChatVisual "..v.prompt.."", mode = "x", desc = "CopilotChat - "..v.desc }) + table.insert(keybinds,{ "cc"..v.key, "CopilotChat "..v.prompt.."", desc = "CopilotChat - "..v.desc }) + end + return keybinds + end, + }, +``` + ## Roadmap - Translation to pure Lua @@ -289,6 +317,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Guruprakash Rajakkannu
Guruprakash Rajakkannu

💻 kristofka
kristofka

💻 + + PostCyberPunk
PostCyberPunk

📖 + diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index d4e5a880..a4361c87 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -285,6 +285,37 @@ Follow the example below to create a simple input for CopilotChat. < +ADD SAME KEYBINDS IN BOTH VISUAL AND NORMAL MODE ~ + +>lua + { + "jellydn/CopilotChat.nvim", + keys = + function() + local keybinds={ + --add your custom keybinds here + } + -- change prompt and keybinds as per your need + local my_prompts = { + {prompt = "In Neovim.",desc = "Neovim",key = "n"}, + {prompt = "Help with this",desc = "Help",key = "h"}, + {prompt = "Simplify and imporve readablilty",desc = "Simplify",key = "s"}, + {prompt = "Optimize the code to improve perfomance and readablilty.",desc = "Optimize",key = "o"}, + {prompt = "Find possible errors and fix them for me",desc = "Fix",key = "f"}, + {prompt = "Explain in detail",desc = "Explain",key = "e"}, + {prompt = "Write a shell scirpt",desc = "Shell",key = "S"}, + } + -- you can change cc to your desired keybind prefix + for _,v in pairs(my_prompts) do + table.insert(keybinds,{ "cc"..v.key, ":CopilotChatVisual "..v.prompt.."", mode = "x", desc = "CopilotChat - "..v.desc }) + table.insert(keybinds,{ "cc"..v.key, "CopilotChat "..v.prompt.."", desc = "CopilotChat - "..v.desc }) + end + return keybinds + end, + }, +< + + ROADMAP *CopilotChat-copilot-chat-for-neovim-roadmap* - Translation to pure Lua @@ -313,14 +344,14 @@ CONTRIBUTORS ✨ *CopilotChat-copilot-chat-for-neovim-contributors-✨* Thanks goes to these wonderful people (emoji key ): -gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻This project follows the all-contributors +gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖This project follows the all-contributors specification. Contributions of any kind welcome! ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square +1. *All Contributors*: https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square 2. *@jellydn*: 3. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif 4. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif From adfeaf757862c864d01617626f35f518ac51c51a Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:46:50 +0800 Subject: [PATCH 22/68] Create FUNDING.yml --- .github/FUNDING.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..949fd0ff --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [gptlang, jellydn] From 135f9681e0db99883e525e6016708f86c400f1b4 Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:07:34 +0800 Subject: [PATCH 23/68] docs: merge my fork to CopilotC-Nvim --- README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 15dc5bb9..5e5996dd 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,6 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-) -> [!NOTE] -> You might want to take a look at [this fork](https://github.com/jellydn/CopilotChat.nvim) which is more well maintained & is more configurable. I personally use it now as well. - > [!NOTE] > A new command, `CopilotChatInPlace` has been introduced. It functions like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart Neovim before starting a chat with Copilot. To stay updated on our roadmap, please join our [Discord](https://discord.gg/vy6hJsTWaZ) community. @@ -25,7 +22,7 @@ It will prompt you with instructions on your first start. If you already have `C ```lua return { { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log @@ -77,7 +74,7 @@ call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/l 1. Put the files in the right place ``` -$ git clone https://github.com/jellydn/CopilotChat.nvim +$ git clone https://github.com/CopilotC-Nvim/CopilotChat.nvim $ cd CopilotChat.nvim $ cp -r --backup=nil rplugin ~/.config/nvim/ ``` @@ -112,7 +109,7 @@ You have the capability to expand the prompts to create more versatile commands: ```lua return { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", opts = { debug = true, show_help = "yes", @@ -189,7 +186,7 @@ A special thanks to @ecosse3 for the configuration of [which-key](https://github ```lua { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", event = "VeryLazy", opts = { prompts = { @@ -254,7 +251,7 @@ Follow the example below to create a simple input for CopilotChat. ```lua { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", keys = function() local keybinds={ From 8730ec7550f457310cd912a0efa50091654f55af Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Mon, 5 Feb 2024 06:53:34 +0000 Subject: [PATCH 24/68] Update funding to use my main account --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 949fd0ff..ce9dcccd 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ # These are supported funding model platforms -github: [gptlang, jellydn] +github: [acheong08, jellydn] From 54e4e79608a84ff31a2d85a50683dce121cc1014 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Tue, 6 Feb 2024 00:15:03 +0800 Subject: [PATCH 25/68] refactor: set min version for Python --- lua/CopilotChat/health.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/CopilotChat/health.lua b/lua/CopilotChat/health.lua index 6677898c..f109065f 100644 --- a/lua/CopilotChat/health.lua +++ b/lua/CopilotChat/health.lua @@ -38,8 +38,8 @@ function M.check() end local major, minor = string.match(python_version, 'Python (%d+)%.(%d+)') - if not (major and minor and tonumber(major) >= 3 and tonumber(minor) >= 7) then - warn('Python version 3.7 or higher is required') + if not (major and minor and tonumber(major) >= 3 and tonumber(minor) >= 10) then + warn('Python version 3.10 or higher is required') else ok('Python version ' .. major .. '.' .. minor .. ' is supported') end From 7d2753ec05835ced0f0e02acb277714070fa54b7 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Tue, 6 Feb 2024 00:19:07 +0800 Subject: [PATCH 26/68] chore: give better naming on chat handler chore: update dict --- cspell-tool.txt | 34 +++++++++++-------- rplugin/python3/handlers/chat_handler.py | 15 ++++---- .../python3/handlers/inplace_chat_handler.py | 1 - 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/cspell-tool.txt b/cspell-tool.txt index 400bb5a2..3893944c 100644 --- a/cspell-tool.txt +++ b/cspell-tool.txt @@ -1,10 +1,17 @@ +keymap pynvim nvim nargs +rplugin +Rplugin +checkhealth +bufnr +noremap Neovim healthcheck bufexists vlog +sysname vararg tjdevries neovim @@ -16,14 +23,19 @@ lineinfo currentline echom tiktoken -jellydn -zbirenbaum -rplugin +Nvim +huynhdung +Autocmd jellydn's ecosse pcall -noremap nowait +keybinds +imporve +readablilty +perfomance +scirpt +keybind gptlang Huynh Haracic @@ -32,20 +44,19 @@ Nguyễn Zhizhou Guruprakash Rajakkannu +kristofka vsplit mypynvim -Nvim AUTOCMD -Autocmd getreg -bufnr autocmd dotenv machineid winnr Nightfly -keymaps +foldmethod linebreak +keymaps diffthis diffoff conceallevel @@ -62,9 +73,4 @@ autocmds shrinked zindex noautocmd -roleplay -vusted -luarocks -isort -checkhealth -sysname \ No newline at end of file +roleplay \ No newline at end of file diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index 3fe7b3d2..e410d8ce 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -16,6 +16,7 @@ def is_module_installed(name): return False +# TODO: Abort request if the user closes the layout class ChatHandler: def __init__(self, nvim: MyNvim, buffer: MyBuffer): self.nvim: MyNvim = nvim @@ -35,7 +36,9 @@ def chat( disable_end_separator: bool = False, model: str = "gpt-4", ): - no_annoyance = self.nvim.eval("g:copilot_chat_disable_separators") == "yes" + disable_separators = ( + self.nvim.eval("g:copilot_chat_disable_separators") == "yes" + ) if system_prompt is None: system_prompt = self._construct_system_prompt(prompt) # Start the spinner @@ -47,7 +50,7 @@ def chat( if not disable_start_separator: self._add_start_separator( - system_prompt, prompt, code, filetype, winnr, no_annoyance + system_prompt, prompt, code, filetype, winnr, disable_separators ) self._add_chat_messages(system_prompt, prompt, code, filetype, model) @@ -56,7 +59,7 @@ def chat( self.nvim.exec_lua('require("CopilotChat.spinner").hide()') if not disable_end_separator: - self._add_end_separator(model, no_annoyance) + self._add_end_separator(model, disable_separators) # private @@ -232,7 +235,7 @@ def _add_chat_messages( token.split("\n"), ) - def _add_end_separator(self, model: str, no_annoyance: bool = False): + def _add_end_separator(self, model: str, disable_separators: bool = False): current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") model_info = f"\n#### Answer provided by Copilot (Model: `{model}`) on {current_datetime}." additional_instructions = ( @@ -242,7 +245,7 @@ def _add_end_separator(self, model: str, no_annoyance: bool = False): end_message = model_info + additional_instructions + disclaimer - if no_annoyance: - end_message = "\n" + current_datetime + "\n---\n" + if disable_separators: + end_message = "\n" + current_datetime + "\n\n---\n" self.buffer.append(end_message.split("\n")) diff --git a/rplugin/python3/handlers/inplace_chat_handler.py b/rplugin/python3/handlers/inplace_chat_handler.py index f0d784f2..dc5db6ac 100644 --- a/rplugin/python3/handlers/inplace_chat_handler.py +++ b/rplugin/python3/handlers/inplace_chat_handler.py @@ -11,7 +11,6 @@ # TODO: change the layout, e.g: move to right side of the screen -# TODO: Abort request if the user closes the layout class InPlaceChatHandler: """This class handles in-place chat functionality.""" From 693b15fc8b68c544058f993773acababe7ceac98 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Tue, 6 Feb 2024 18:54:43 +0800 Subject: [PATCH 27/68] docs: add python support version on readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 5e5996dd..1b234aed 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,20 @@ # Copilot Chat for Neovim + [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-) + > [!NOTE] > A new command, `CopilotChatInPlace` has been introduced. It functions like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart Neovim before starting a chat with Copilot. To stay updated on our roadmap, please join our [Discord](https://discord.gg/vy6hJsTWaZ) community. +## Prerequisites + +Ensure you have the following installed: + +- Python 3.10 or later + ## Authentication It will prompt you with instructions on your first start. If you already have `Copilot.vim` or `Copilot.lua`, it will work automatically. From 94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Tue, 6 Feb 2024 20:04:07 +0800 Subject: [PATCH 28/68] fix(ci): generate vimdoc on main branch fix(ci): skip git hook on vimdoc --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8123c9e1..1b355bf7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,15 @@ jobs: docs: runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository. + contents: write name: pandoc to vimdoc if: ${{ github.ref == 'refs/heads/main' }} steps: - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: panvimdoc uses: kdheepak/panvimdoc@main with: @@ -31,6 +36,7 @@ jobs: commit_user_name: "github-actions[bot]" commit_user_email: "github-actions[bot]@users.noreply.github.com" commit_author: "github-actions[bot] " + commit_options: "--no-verify" test: name: Run Test From 95d7c2deb36e7f99288bac568ed44ef53fe0a541 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 6 Feb 2024 12:08:03 +0000 Subject: [PATCH 29/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index a4361c87..502997ca 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,9 +1,10 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 05 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 06 ============================================================================== Table of Contents *CopilotChat-table-of-contents* 1. Copilot Chat for Neovim |CopilotChat-copilot-chat-for-neovim| + - Prerequisites |CopilotChat-copilot-chat-for-neovim-prerequisites| - Authentication |CopilotChat-copilot-chat-for-neovim-authentication| - Installation |CopilotChat-copilot-chat-for-neovim-installation| - Usage |CopilotChat-copilot-chat-for-neovim-usage| @@ -18,15 +19,18 @@ Table of Contents *CopilotChat-table-of-contents* |CopilotChat-| - [!NOTE] You might want to take a look at this fork - which is more well maintained & - is more configurable. I personally use it now as well. - [!NOTE] A new command, `CopilotChatInPlace` has been introduced. It functions like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart Neovim before starting a chat with Copilot. To stay updated on our roadmap, please join our Discord community. +PREREQUISITES *CopilotChat-copilot-chat-for-neovim-prerequisites* + +Ensure you have the following installed: + +- Python 3.10 or later + + AUTHENTICATION *CopilotChat-copilot-chat-for-neovim-authentication* It will prompt you with instructions on your first start. If you already have @@ -45,7 +49,7 @@ LAZY.NVIM ~ >lua return { { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log @@ -98,7 +102,7 @@ MANUAL ~ 1. Put the files in the right place > - $ git clone https://github.com/jellydn/CopilotChat.nvim + $ git clone https://github.com/CopilotC-Nvim/CopilotChat.nvim $ cd CopilotChat.nvim $ cp -r --backup=nil rplugin ~/.config/nvim/ < @@ -137,7 +141,7 @@ commands: >lua return { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", opts = { debug = true, show_help = "yes", @@ -222,7 +226,7 @@ A special thanks to @ecosse3 for the configuration of which-key >lua { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", event = "VeryLazy", opts = { prompts = { @@ -289,7 +293,7 @@ ADD SAME KEYBINDS IN BOTH VISUAL AND NORMAL MODE ~ >lua { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", keys = function() local keybinds={ From 2f1e0466af30c26fdcd2b94d331ea4004d32bb07 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Tue, 6 Feb 2024 20:38:42 +0800 Subject: [PATCH 30/68] fix(ci): setup release action --- .github/workflows/release.yml | 5 +++++ version.txt | 1 + 2 files changed, 6 insertions(+) create mode 100644 version.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6f3d1425..a0cc66fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,10 @@ on: - main - release +permissions: + contents: write + pull-requests: write + jobs: release: name: release @@ -18,6 +22,7 @@ jobs: with: release-type: simple package-name: CopilotChat.nvim + token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v3 - name: tag stable versions if: ${{ steps.release.outputs.release_created }} diff --git a/version.txt b/version.txt new file mode 100644 index 00000000..26aaba0e --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +1.2.0 From 96b8ebfff439cbb00f44331578c88019da45f543 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 20:44:10 +0800 Subject: [PATCH 31/68] chore(main): release 1.0.0 (#29) * chore(main): release 1.0.0 * chore: remove old changelog * Update CHANGELOG.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Dung Duc Huynh (Kaka) <870029+jellydn@users.noreply.github.com> --- CHANGELOG.md | 68 ++++++++++++++++++---------------------------------- version.txt | 2 +- 2 files changed, 24 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ccfe4ef..6e76e454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,57 +1,35 @@ # Changelog -## [1.2.1](https://github.com/jellydn/CopilotChat.nvim/compare/v1.2.0...v1.2.1) (2024-02-05) +## 1.0.0 (2024-02-06) -### Reverts - -* **ci:** add release workflow back ([81a9d81](https://github.com/jellydn/CopilotChat.nvim/commit/81a9d818b1369d41108c46da477e4ea5cec0a525)) - -## [1.2.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-04) - -### Features - -- show date time and additional information on end separator ([#53](https://github.com/jellydn/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/jellydn/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) - -### Bug Fixes - -- handle get remote plugin path on Windows ([0b917f6](https://github.com/jellydn/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) - -## [1.1.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.0.0...v1.1.0) (2024-02-04) - -### Features - -- add CopilotChatDebugInfo command ([#51](https://github.com/jellydn/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/jellydn/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) - -## 1.0.0 (2024-02-03) - ### ⚠ BREAKING CHANGES -- drop new buffer mode +* disable extra info as default +* drop new buffer mode ### Features -- add a note for help user to continue the chat ([8a80ee7](https://github.com/jellydn/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) -- add CCExplain command ([640f361](https://github.com/jellydn/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) -- add CCTests command ([b34a78f](https://github.com/jellydn/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) -- add configuration options for wrap and filetype ([b4c6e76](https://github.com/jellydn/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) -- add CopilotChatToggleLayout ([07988b9](https://github.com/jellydn/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) -- add debug flag ([d0dbd4c](https://github.com/jellydn/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) -- add health check ([974f14f](https://github.com/jellydn/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) -- add new keymap to get previous user prompt ([6e7e80f](https://github.com/jellydn/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) -- set filetype to markdown and text wrapping ([9b19d51](https://github.com/jellydn/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) -- show chat in markdown format ([9c14152](https://github.com/jellydn/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) +* add a note for help user to continue the chat ([8a80ee7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) +* add CCExplain command ([640f361](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) +* add CCTests command ([b34a78f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) +* add configuration options for wrap and filetype ([b4c6e76](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) +* add CopilotChatDebugInfo command ([#51](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) +* add CopilotChatToggleLayout ([07988b9](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) +* add debug flag ([d0dbd4c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) +* add health check ([974f14f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) +* add new keymap to get previous user prompt ([6e7e80f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) +* set filetype to markdown and text wrapping ([9b19d51](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) +* show chat in markdown format ([9c14152](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) +* show date time and additional information on end separator ([#53](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) -### Bug Fixes -- **ci:** generate doc ([6287fd4](https://github.com/jellydn/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) -- Close spinner if the buffer does not exist ([#11](https://github.com/jellydn/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/jellydn/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) -- remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/jellydn/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/jellydn/CopilotChat.nvim/issues/45) - -### Reverts - -- change back to CopilotChat command ([e304f79](https://github.com/jellydn/CopilotChat.nvim/commit/e304f792a5fbba412c2a5a1f717ec7e2ab12e5b0)) - -### Code Refactoring +### Bug Fixes -- drop new buffer mode ([0a30b7c](https://github.com/jellydn/CopilotChat.nvim/commit/0a30b7cfbd8b52bf8a9e4cd96dcade4995e6eb3a)) +* **ci:** generate doc ([6287fd4](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) +* **ci:** generate vimdoc on main branch ([94fb10c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb)) +* **ci:** setup release action ([2f1e046](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/2f1e0466af30c26fdcd2b94d331ea4004d32bb07)) +* **ci:** skip git hook on vimdoc ([94fb10c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb)) +* Close spinner if the buffer does not exist ([#11](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) +* handle get remote plugin path on Windows ([0b917f6](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) +* remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45) diff --git a/version.txt b/version.txt index 26aaba0e..3eefcb9d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.2.0 +1.0.0 From ebf5134b986b5d490aca1a0b0430bb43a6bd29a8 Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:46:52 +0800 Subject: [PATCH 32/68] docs: add stargazers over time --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b234aed..8ccf84a2 100644 --- a/README.md +++ b/README.md @@ -333,4 +333,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome! + +### Stargazers over time + +[![Stargazers over time](https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg)](https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim) From 90225329f083ad21d7f31ed731047750382f053e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 Feb 2024 02:47:10 +0000 Subject: [PATCH 33/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 502997ca..145a39b9 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 06 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 07 ============================================================================== Table of Contents *CopilotChat-table-of-contents* @@ -350,7 +350,12 @@ Thanks goes to these wonderful people (emoji key gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖This project follows the all-contributors specification. -Contributions of any kind welcome! +Contributions of any kind are welcome! + + +STARGAZERS OVER TIME ~ + + ============================================================================== 2. Links *CopilotChat-links* @@ -364,6 +369,7 @@ Contributions of any kind welcome! 7. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif 8. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif 9. *@ecosse3*: +10. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg Generated by panvimdoc From a734732055ee82e2f99786daa7ed45ee620557e6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 8 Feb 2024 12:23:19 +0000 Subject: [PATCH 34/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 145a39b9..facc0432 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 07 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 08 ============================================================================== Table of Contents *CopilotChat-table-of-contents* From 20a4234a542deef1a128aca4d0dd7e8d429a1f2a Mon Sep 17 00:00:00 2001 From: gptlang Date: Thu, 8 Feb 2024 12:23:43 +0000 Subject: [PATCH 35/68] fix: multi-byte languages by manually tracking last_line_col for buf_set_text --- .all-contributorsrc | 38 +++++--------------- CHANGELOG.md | 44 +++++++++++------------- rplugin/python3/copilot.py | 7 ++-- rplugin/python3/handlers/chat_handler.py | 6 ++-- 4 files changed, 38 insertions(+), 57 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 59f826dd..034e0948 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,5 @@ { - "files": [ - "README.md" - ], + "files": ["README.md"], "imageSize": 100, "commit": false, "commitType": "docs", @@ -12,74 +10,56 @@ "name": "gptlang", "avatar_url": "https://avatars.githubusercontent.com/u/121417512?v=4", "profile": "https://github.com/gptlang", - "contributions": [ - "code", - "doc" - ] + "contributions": ["code", "doc"] }, { "login": "jellydn", "name": "Dung Duc Huynh (Kaka)", "avatar_url": "https://avatars.githubusercontent.com/u/870029?v=4", "profile": "https://productsway.com/", - "contributions": [ - "code", - "doc" - ] + "contributions": ["code", "doc"] }, { "login": "qoobes", "name": "Ahmed Haracic", "avatar_url": "https://avatars.githubusercontent.com/u/58834655?v=4", "profile": "https://qoobes.dev", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "ziontee113", "name": "Trí Thiện Nguyễn", "avatar_url": "https://avatars.githubusercontent.com/u/102876811?v=4", "profile": "https://youtube.com/@ziontee113", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "Cassius0924", "name": "He Zhizhou", "avatar_url": "https://avatars.githubusercontent.com/u/62874592?v=4", "profile": "https://github.com/Cassius0924", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "rguruprakash", "name": "Guruprakash Rajakkannu", "avatar_url": "https://avatars.githubusercontent.com/u/9963717?v=4", "profile": "https://www.linkedin.com/in/guruprakashrajakkannu/", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "kristofka", "name": "kristofka", "avatar_url": "https://avatars.githubusercontent.com/u/140354?v=4", "profile": "https://github.com/kristofka", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "PostCyberPunk", "name": "PostCyberPunk", "avatar_url": "https://avatars.githubusercontent.com/u/134976996?v=4", "profile": "https://github.com/PostCyberPunk", - "contributions": [ - "doc" - ] + "contributions": ["doc"] } ], "contributorsPerLine": 7, diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e76e454..df286ceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,34 +2,32 @@ ## 1.0.0 (2024-02-06) - ### ⚠ BREAKING CHANGES -* disable extra info as default -* drop new buffer mode +- disable extra info as default +- drop new buffer mode ### Features -* add a note for help user to continue the chat ([8a80ee7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) -* add CCExplain command ([640f361](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) -* add CCTests command ([b34a78f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) -* add configuration options for wrap and filetype ([b4c6e76](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) -* add CopilotChatDebugInfo command ([#51](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) -* add CopilotChatToggleLayout ([07988b9](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) -* add debug flag ([d0dbd4c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) -* add health check ([974f14f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) -* add new keymap to get previous user prompt ([6e7e80f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) -* set filetype to markdown and text wrapping ([9b19d51](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) -* show chat in markdown format ([9c14152](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) -* show date time and additional information on end separator ([#53](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) - +- add a note for help user to continue the chat ([8a80ee7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) +- add CCExplain command ([640f361](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) +- add CCTests command ([b34a78f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) +- add configuration options for wrap and filetype ([b4c6e76](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) +- add CopilotChatDebugInfo command ([#51](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) +- add CopilotChatToggleLayout ([07988b9](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) +- add debug flag ([d0dbd4c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) +- add health check ([974f14f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) +- add new keymap to get previous user prompt ([6e7e80f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) +- set filetype to markdown and text wrapping ([9b19d51](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) +- show chat in markdown format ([9c14152](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) +- show date time and additional information on end separator ([#53](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) ### Bug Fixes -* **ci:** generate doc ([6287fd4](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) -* **ci:** generate vimdoc on main branch ([94fb10c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb)) -* **ci:** setup release action ([2f1e046](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/2f1e0466af30c26fdcd2b94d331ea4004d32bb07)) -* **ci:** skip git hook on vimdoc ([94fb10c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb)) -* Close spinner if the buffer does not exist ([#11](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) -* handle get remote plugin path on Windows ([0b917f6](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) -* remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45) +- **ci:** generate doc ([6287fd4](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) +- **ci:** generate vimdoc on main branch ([94fb10c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb)) +- **ci:** setup release action ([2f1e046](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/2f1e0466af30c26fdcd2b94d331ea4004d32bb07)) +- **ci:** skip git hook on vimdoc ([94fb10c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb)) +- Close spinner if the buffer does not exist ([#11](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) +- handle get remote plugin path on Windows ([0b917f6](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) +- remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45) diff --git a/rplugin/python3/copilot.py b/rplugin/python3/copilot.py index ee471b64..4a86ae26 100644 --- a/rplugin/python3/copilot.py +++ b/rplugin/python3/copilot.py @@ -127,10 +127,11 @@ def ask( ) ) for line in response.iter_lines(): - line = line.decode("utf-8").replace("data: ", "").strip() - if line.startswith("[DONE]"): + line: bytes = line + line = line.replace(b"data: ", b"") + if line.startswith(b"[DONE]"): break - elif line == "": + elif line == b"": continue try: line = json.loads(line) diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index e410d8ce..166af537 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -216,6 +216,7 @@ def _add_chat_messages( self.nvim.out_write("Successfully authenticated with Copilot\n") self.copilot.authenticate() + last_line_col = 0 for token in self.copilot.ask( system_prompt, prompt, code, language=cast(str, file_type), model=model ): @@ -224,8 +225,6 @@ def _add_chat_messages( ) buffer_lines = cast(list[str], self.buffer.lines()) last_line_row = len(buffer_lines) - 1 - last_line_col = len(buffer_lines[-1]) - self.nvim.api.buf_set_text( self.buffer.number, last_line_row, @@ -234,6 +233,9 @@ def _add_chat_messages( last_line_col, token.split("\n"), ) + last_line_col += len(token.encode("utf-8")) + if "\n" in token: + last_line_col = 0 def _add_end_separator(self, model: str, disable_separators: bool = False): current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") From c4027f2c82f70eedbeddc39f01092555361cd28e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 20:34:35 +0800 Subject: [PATCH 36/68] chore(main): release 1.0.1 (#33) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ version.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df286ceb..8fb88ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.0.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.0...v1.0.1) (2024-02-08) + + +### Bug Fixes + +* multi-byte languages by manually tracking last_line_col for buf_set_text ([20a4234](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/20a4234a542deef1a128aca4d0dd7e8d429a1f2a)) + ## 1.0.0 (2024-02-06) ### ⚠ BREAKING CHANGES diff --git a/version.txt b/version.txt index 3eefcb9d..7dea76ed 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.0 +1.0.1 From 589a4538d648c8723d839ca963a47a6176be3c78 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Thu, 8 Feb 2024 23:54:01 +0800 Subject: [PATCH 37/68] feat(chat_handler): show extra info only once --- rplugin/python3/handlers/chat_handler.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index 166af537..2d9ade76 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -18,6 +18,8 @@ def is_module_installed(name): # TODO: Abort request if the user closes the layout class ChatHandler: + has_show_extra_info = False + def __init__(self, nvim: MyNvim, buffer: MyBuffer): self.nvim: MyNvim = nvim self.copilot: Copilot = None @@ -247,7 +249,11 @@ def _add_end_separator(self, model: str, disable_separators: bool = False): end_message = model_info + additional_instructions + disclaimer - if disable_separators: + show_extra = disable_separators or ChatHandler.has_show_extra_info + + if show_extra: end_message = "\n" + current_datetime + "\n\n---\n" + ChatHandler.has_show_extra_info = True + self.buffer.append(end_message.split("\n")) From be23873f2a752705b7e9e034bda6df09351c7e48 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Thu, 8 Feb 2024 23:58:56 +0800 Subject: [PATCH 38/68] ci: add todo workflow --- .github/workflows/todo.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/todo.yml diff --git a/.github/workflows/todo.yml b/.github/workflows/todo.yml new file mode 100644 index 00000000..cc131582 --- /dev/null +++ b/.github/workflows/todo.yml @@ -0,0 +1,10 @@ +name: "Run TODO to Issue" + +on: ["push"] +jobs: + build: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - name: "TODO to Issue" + uses: "alstr/todo-to-issue-action@v4" From 19a8088c171cb956fd553200b77c8dbbe76707b6 Mon Sep 17 00:00:00 2001 From: gptlang Date: Fri, 9 Feb 2024 20:03:18 +0000 Subject: [PATCH 39/68] feat: Proxy support --- CHANGELOG.md | 3 +-- README.md | 1 + lua/CopilotChat/init.lua | 1 + rplugin/python3/copilot.py | 5 ++++- rplugin/python3/handlers/chat_handler.py | 7 ++++++- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fb88ce0..98a1032a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,9 @@ ## [1.0.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.0...v1.0.1) (2024-02-08) - ### Bug Fixes -* multi-byte languages by manually tracking last_line_col for buf_set_text ([20a4234](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/20a4234a542deef1a128aca4d0dd7e8d429a1f2a)) +- multi-byte languages by manually tracking last_line_col for buf_set_text ([20a4234](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/20a4234a542deef1a128aca4d0dd7e8d429a1f2a)) ## 1.0.0 (2024-02-06) diff --git a/README.md b/README.md index 8ccf84a2..05958b6d 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ return { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log disable_extra_info = 'no', -- Disable extra information (e.g: system prompt) in the response. + -- proxy = "socks5://127.0.0.1:3000", -- Proxies requests via https or socks. }, build = function() vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.") diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 9fe5f325..08b2de8d 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -18,6 +18,7 @@ _COPILOT_CHAT_GLOBAL_CONFIG = {} M.setup = function(options) vim.g.copilot_chat_show_help = options and options.show_help or 'yes' vim.g.copilot_chat_disable_separators = options and options.disable_extra_info or 'yes' + vim.g.copilot_chat_proxy = options and options.proxy or '' local debug = options and options.debug or false _COPILOT_CHAT_GLOBAL_CONFIG.debug = debug diff --git a/rplugin/python3/copilot.py b/rplugin/python3/copilot.py index 4a86ae26..25dbba67 100644 --- a/rplugin/python3/copilot.py +++ b/rplugin/python3/copilot.py @@ -22,7 +22,7 @@ class Copilot: - def __init__(self, token: str = None): + def __init__(self, token: str = None, proxy: str = None): if token is None: token = utilities.get_cached_token() self.github_token = token @@ -33,6 +33,9 @@ def __init__(self, token: str = None): self.session = requests.Session() + if proxy: + self.session.proxies = {"https": proxy} + def request_auth(self): url = "https://github.com/login/device/code" diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index 2d9ade76..d585bddd 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -24,6 +24,7 @@ def __init__(self, nvim: MyNvim, buffer: MyBuffer): self.nvim: MyNvim = nvim self.copilot: Copilot = None self.buffer: MyBuffer = buffer + self.proxy: str = None # public @@ -41,6 +42,10 @@ def chat( disable_separators = ( self.nvim.eval("g:copilot_chat_disable_separators") == "yes" ) + self.proxy = self.nvim.eval("g:copilot_chat_proxy") + if "://" not in self.proxy: + self.proxy = None + if system_prompt is None: system_prompt = self._construct_system_prompt(prompt) # Start the spinner @@ -201,7 +206,7 @@ def _add_chat_messages( self, system_prompt: str, prompt: str, code: str, file_type: str, model: str ): if self.copilot is None: - self.copilot = Copilot() + self.copilot = Copilot(proxy=self.proxy) if self.copilot.github_token is None: req = self.copilot.request_auth() self.nvim.out_write( From 043e731005278649dbdf1d5866c6e3c7719f1202 Mon Sep 17 00:00:00 2001 From: gptlang Date: Fri, 9 Feb 2024 20:05:50 +0000 Subject: [PATCH 40/68] feat: Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) --- rplugin/python3/handlers/chat_handler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index d585bddd..e81cb2d8 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -1,6 +1,7 @@ import time from datetime import datetime from typing import Optional, cast +import os import prompts as system_prompts from copilot import Copilot @@ -24,7 +25,7 @@ def __init__(self, nvim: MyNvim, buffer: MyBuffer): self.nvim: MyNvim = nvim self.copilot: Copilot = None self.buffer: MyBuffer = buffer - self.proxy: str = None + self.proxy: str = os.getenv("HTTPS_PROXY") or os.getenv("ALL_PROXY") or "" # public From e87f21ef387cb3dc0f6fb9e986bf4e41b85b5797 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 9 Feb 2024 20:06:29 +0000 Subject: [PATCH 41/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index facc0432..1cdaa3ce 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 08 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 09 ============================================================================== Table of Contents *CopilotChat-table-of-contents* @@ -54,6 +54,7 @@ LAZY.NVIM ~ show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log disable_extra_info = 'no', -- Disable extra information (e.g: system prompt) in the response. + -- proxy = "socks5://127.0.0.1:3000", -- Proxies requests via https or socks. }, build = function() vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.") From c5bf963f4702a8a94aa97de2e6205796cb381ae5 Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Fri, 9 Feb 2024 20:08:01 +0000 Subject: [PATCH 42/68] fix: Wacky indentation in readme --- README.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 05958b6d..41eabc4f 100644 --- a/README.md +++ b/README.md @@ -262,27 +262,27 @@ Follow the example below to create a simple input for CopilotChat. { "CopilotC-Nvim/CopilotChat.nvim", keys = - function() - local keybinds={ - --add your custom keybinds here - } - -- change prompt and keybinds as per your need - local my_prompts = { - {prompt = "In Neovim.",desc = "Neovim",key = "n"}, - {prompt = "Help with this",desc = "Help",key = "h"}, - {prompt = "Simplify and imporve readablilty",desc = "Simplify",key = "s"}, - {prompt = "Optimize the code to improve perfomance and readablilty.",desc = "Optimize",key = "o"}, - {prompt = "Find possible errors and fix them for me",desc = "Fix",key = "f"}, - {prompt = "Explain in detail",desc = "Explain",key = "e"}, - {prompt = "Write a shell scirpt",desc = "Shell",key = "S"}, - } - -- you can change cc to your desired keybind prefix - for _,v in pairs(my_prompts) do - table.insert(keybinds,{ "cc"..v.key, ":CopilotChatVisual "..v.prompt.."", mode = "x", desc = "CopilotChat - "..v.desc }) - table.insert(keybinds,{ "cc"..v.key, "CopilotChat "..v.prompt.."", desc = "CopilotChat - "..v.desc }) - end - return keybinds - end, + function() + local keybinds={ + --add your custom keybinds here + } + -- change prompt and keybinds as per your need + local my_prompts = { + {prompt = "In Neovim.",desc = "Neovim",key = "n"}, + {prompt = "Help with this",desc = "Help",key = "h"}, + {prompt = "Simplify and imporve readablilty",desc = "Simplify",key = "s"}, + {prompt = "Optimize the code to improve perfomance and readablilty.",desc = "Optimize",key = "o"}, + {prompt = "Find possible errors and fix them for me",desc = "Fix",key = "f"}, + {prompt = "Explain in detail",desc = "Explain",key = "e"}, + {prompt = "Write a shell scirpt",desc = "Shell",key = "S"}, + } + -- you can change cc to your desired keybind prefix + for _,v in pairs(my_prompts) do + table.insert(keybinds,{ "cc"..v.key, ":CopilotChatVisual "..v.prompt.."", mode = "x", desc = "CopilotChat - "..v.desc }) + table.insert(keybinds,{ "cc"..v.key, "CopilotChat "..v.prompt.."", desc = "CopilotChat - "..v.desc }) + end + return keybinds + end, }, ``` From 3ab40e29402bcad03a710c6dff2cf74dcbb11e6d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 9 Feb 2024 20:08:22 +0000 Subject: [PATCH 43/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 1cdaa3ce..daf86a2e 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -296,27 +296,27 @@ ADD SAME KEYBINDS IN BOTH VISUAL AND NORMAL MODE ~ { "CopilotC-Nvim/CopilotChat.nvim", keys = - function() - local keybinds={ - --add your custom keybinds here - } - -- change prompt and keybinds as per your need - local my_prompts = { - {prompt = "In Neovim.",desc = "Neovim",key = "n"}, - {prompt = "Help with this",desc = "Help",key = "h"}, - {prompt = "Simplify and imporve readablilty",desc = "Simplify",key = "s"}, - {prompt = "Optimize the code to improve perfomance and readablilty.",desc = "Optimize",key = "o"}, - {prompt = "Find possible errors and fix them for me",desc = "Fix",key = "f"}, - {prompt = "Explain in detail",desc = "Explain",key = "e"}, - {prompt = "Write a shell scirpt",desc = "Shell",key = "S"}, - } - -- you can change cc to your desired keybind prefix - for _,v in pairs(my_prompts) do - table.insert(keybinds,{ "cc"..v.key, ":CopilotChatVisual "..v.prompt.."", mode = "x", desc = "CopilotChat - "..v.desc }) - table.insert(keybinds,{ "cc"..v.key, "CopilotChat "..v.prompt.."", desc = "CopilotChat - "..v.desc }) - end - return keybinds - end, + function() + local keybinds={ + --add your custom keybinds here + } + -- change prompt and keybinds as per your need + local my_prompts = { + {prompt = "In Neovim.",desc = "Neovim",key = "n"}, + {prompt = "Help with this",desc = "Help",key = "h"}, + {prompt = "Simplify and imporve readablilty",desc = "Simplify",key = "s"}, + {prompt = "Optimize the code to improve perfomance and readablilty.",desc = "Optimize",key = "o"}, + {prompt = "Find possible errors and fix them for me",desc = "Fix",key = "f"}, + {prompt = "Explain in detail",desc = "Explain",key = "e"}, + {prompt = "Write a shell scirpt",desc = "Shell",key = "S"}, + } + -- you can change cc to your desired keybind prefix + for _,v in pairs(my_prompts) do + table.insert(keybinds,{ "cc"..v.key, ":CopilotChatVisual "..v.prompt.."", mode = "x", desc = "CopilotChat - "..v.desc }) + table.insert(keybinds,{ "cc"..v.key, "CopilotChat "..v.prompt.."", desc = "CopilotChat - "..v.desc }) + end + return keybinds + end, }, < From e98f5f4eb5dd890f5fe320abc5dc79cc0637d23d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 10 Feb 2024 08:30:12 +0800 Subject: [PATCH 44/68] chore(main): release 1.1.0 (#37) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 14 ++++++++++++++ version.txt | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98a1032a..271c534c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [1.1.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.1...v1.1.0) (2024-02-10) + + +### Features + +* **chat_handler:** show extra info only once ([589a453](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/589a4538d648c8723d839ca963a47a6176be3c78)) +* Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) ([043e731](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/043e731005278649dbdf1d5866c6e3c7719f1202)) +* Proxy support ([19a8088](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/19a8088c171cb956fd553200b77c8dbbe76707b6)) + + +### Bug Fixes + +* Wacky indentation in readme ([c5bf963](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/c5bf963f4702a8a94aa97de2e6205796cb381ae5)) + ## [1.0.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.0...v1.0.1) (2024-02-08) ### Bug Fixes diff --git a/version.txt b/version.txt index 7dea76ed..9084fa2f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.1 +1.1.0 From 3e9c0009ad9dfa5c2504833c284d6eb7764df0ef Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 10 Feb 2024 00:30:30 +0000 Subject: [PATCH 45/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index daf86a2e..605b4ca2 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 09 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 10 ============================================================================== Table of Contents *CopilotChat-table-of-contents* From 9fa7d860c970a40315cff887dd5baec8e2da07fe Mon Sep 17 00:00:00 2001 From: gptlang <121417512+gptlang@users.noreply.github.com> Date: Sat, 10 Feb 2024 09:29:24 +0000 Subject: [PATCH 46/68] Update wishlist/roadmap --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 41eabc4f..d08462bf 100644 --- a/README.md +++ b/README.md @@ -286,12 +286,11 @@ Follow the example below to create a simple input for CopilotChat. }, ``` -## Roadmap +## Roadmap (Wishlist) -- Translation to pure Lua -- Tokenizer - Use vector encodings to automatically select code -- Sub commands - See [issue #5](https://github.com/gptlang/CopilotChat.nvim/issues/5) +- Treesitter integration for function definitions +- General QOL improvements ## Development From a9cbd1272e718f2166b9428d292a6fc77aaa1d0a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 10 Feb 2024 09:29:52 +0000 Subject: [PATCH 47/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 605b4ca2..19b0ef7c 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -9,7 +9,7 @@ Table of Contents *CopilotChat-table-of-contents* - Installation |CopilotChat-copilot-chat-for-neovim-installation| - Usage |CopilotChat-copilot-chat-for-neovim-usage| - Tips |CopilotChat-copilot-chat-for-neovim-tips| - - Roadmap |CopilotChat-copilot-chat-for-neovim-roadmap| + - Roadmap (Wishlist)|CopilotChat-copilot-chat-for-neovim-roadmap-(wishlist)| - Development |CopilotChat-copilot-chat-for-neovim-development| - Contributors ✨ |CopilotChat-copilot-chat-for-neovim-contributors-✨| @@ -321,12 +321,11 @@ ADD SAME KEYBINDS IN BOTH VISUAL AND NORMAL MODE ~ < -ROADMAP *CopilotChat-copilot-chat-for-neovim-roadmap* +ROADMAP (WISHLIST) *CopilotChat-copilot-chat-for-neovim-roadmap-(wishlist)* -- Translation to pure Lua -- Tokenizer - Use vector encodings to automatically select code -- Sub commands - See issue #5 +- Treesitter integration for function definitions +- General QOL improvements DEVELOPMENT *CopilotChat-copilot-chat-for-neovim-development* From bdba2eb8a6faf2ca5c844c1802e3e04cacba765d Mon Sep 17 00:00:00 2001 From: Katsuhiko Nishimra Date: Sun, 11 Feb 2024 17:14:45 +0900 Subject: [PATCH 48/68] chore: use g:python3_host_prog for health check --- lua/CopilotChat/health.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/CopilotChat/health.lua b/lua/CopilotChat/health.lua index f109065f..18189cb3 100644 --- a/lua/CopilotChat/health.lua +++ b/lua/CopilotChat/health.lua @@ -24,7 +24,8 @@ end --- Run a python command and handle potential errors ---@param command string local function run_python_command(command) - return run_command_on_executable('python3', command) + local python3_host_prog = vim.g["python3_host_prog"] + return run_command_on_executable(python3_host_prog or 'python3', command) end -- Add health check for python3 and pynvim From 8891cc6a1ae04e792e584af6640c313b65d4f5eb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 11 Feb 2024 08:15:06 +0000 Subject: [PATCH 49/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 19b0ef7c..c8f7ecda 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 10 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 11 ============================================================================== Table of Contents *CopilotChat-table-of-contents* From bbdce792555020999a431828b96777e00d65a78e Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sun, 11 Feb 2024 16:31:36 +0800 Subject: [PATCH 50/68] chore: fix ci lint issue --- lua/CopilotChat/health.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/CopilotChat/health.lua b/lua/CopilotChat/health.lua index 18189cb3..09ca5b96 100644 --- a/lua/CopilotChat/health.lua +++ b/lua/CopilotChat/health.lua @@ -24,7 +24,7 @@ end --- Run a python command and handle potential errors ---@param command string local function run_python_command(command) - local python3_host_prog = vim.g["python3_host_prog"] + local python3_host_prog = vim.g['python3_host_prog'] return run_command_on_executable(python3_host_prog or 'python3', command) end From 45dd4f3ff5f834adb268664015d7b0191e120453 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sun, 11 Feb 2024 16:37:39 +0800 Subject: [PATCH 51/68] docs: add ktns for code --- .all-contributorsrc | 7 +++++++ README.md | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 034e0948..af526419 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -60,6 +60,13 @@ "avatar_url": "https://avatars.githubusercontent.com/u/134976996?v=4", "profile": "https://github.com/PostCyberPunk", "contributions": ["doc"] + }, + { + "login": "ktns", + "name": "Katsuhiko Nishimra", + "avatar_url": "https://avatars.githubusercontent.com/u/1302759?v=4", + "profile": "https://github.com/ktns", + "contributions": ["code"] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index d08462bf..b5a5cae4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-) @@ -324,6 +324,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d PostCyberPunk
PostCyberPunk

📖 + Katsuhiko Nishimra
Katsuhiko Nishimra

💻 From a34b639fd57e2593fd0549d3f5251ee4d30a3569 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 11 Feb 2024 08:38:02 +0000 Subject: [PATCH 52/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index c8f7ecda..fdd2053f 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -348,7 +348,7 @@ CONTRIBUTORS ✨ *CopilotChat-copilot-chat-for-neovim-contributors-✨* Thanks goes to these wonderful people (emoji key ): -gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖This project follows the all-contributors +gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖Katsuhiko Nishimra💻This project follows the all-contributors specification. Contributions of any kind are welcome! @@ -360,7 +360,7 @@ STARGAZERS OVER TIME ~ ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square +1. *All Contributors*: https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square 2. *@jellydn*: 3. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif 4. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif From 0492c54db77d81763c0ed1d0bcf951a9fc7c2395 Mon Sep 17 00:00:00 2001 From: Shaun Garwood Date: Mon, 12 Feb 2024 19:21:05 -0700 Subject: [PATCH 53/68] chore: fixed a typo in the prompt (#43) --- lua/CopilotChat/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 08b2de8d..1542e0f9 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -4,7 +4,7 @@ local M = {} local default_prompts = { Explain = 'Explain how it works.', - Tests = 'Briefly how selected code works then generate unit tests.', + Tests = 'Briefly explain how selected code works then generate unit tests.', } _COPILOT_CHAT_GLOBAL_CONFIG = {} From 5f53f71ca2431b0d9f29ebe6853ba682afa8a95b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 13 Feb 2024 02:21:27 +0000 Subject: [PATCH 54/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index fdd2053f..b4c0a27e 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 11 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 13 ============================================================================== Table of Contents *CopilotChat-table-of-contents* From 81abf4f71cfd7fada3f05f6b24bfad175d621342 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Tue, 13 Feb 2024 10:23:20 +0800 Subject: [PATCH 55/68] docs: add shaungarwood contributor for code --- .all-contributorsrc | 7 +++++++ README.md | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index af526419..6d3e511e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -67,6 +67,13 @@ "avatar_url": "https://avatars.githubusercontent.com/u/1302759?v=4", "profile": "https://github.com/ktns", "contributions": ["code"] + }, + { + "login": "shaungarwood", + "name": "Shaun Garwood", + "avatar_url": "https://avatars.githubusercontent.com/u/4156525?v=4", + "profile": "https://github.com/shaungarwood", + "contributions": ["code"] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index b5a5cae4..d1ea7da0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-) @@ -325,6 +325,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d PostCyberPunk
PostCyberPunk

📖 Katsuhiko Nishimra
Katsuhiko Nishimra

💻 + Shaun Garwood
Shaun Garwood

💻 From a38198c8c3d2ffc32b38551de18b3c86dca2a248 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 13 Feb 2024 02:23:56 +0000 Subject: [PATCH 56/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index b4c0a27e..83145d03 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -348,7 +348,7 @@ CONTRIBUTORS ✨ *CopilotChat-copilot-chat-for-neovim-contributors-✨* Thanks goes to these wonderful people (emoji key ): -gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖Katsuhiko Nishimra💻This project follows the all-contributors +gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖Katsuhiko Nishimra💻Shaun Garwood💻This project follows the all-contributors specification. Contributions of any kind are welcome! @@ -360,7 +360,7 @@ STARGAZERS OVER TIME ~ ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square +1. *All Contributors*: https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square 2. *@jellydn*: 3. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif 4. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif From 52350c78dbcfcb3acabf3478276ad9a87ebbfd26 Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Tue, 13 Feb 2024 23:35:07 +0800 Subject: [PATCH 57/68] feat: restructure for pynvim 0.4.3 backwards compatibility (#45) * feat: restructure for pynvim 0.4.3 backwards compatibility * move files under subdirectory * change to use local relative imports * fix healthcheck to support pynvim 0.4.3 and use correct python version * Fix imports again * chore: add errnoh for code * fix(ci): fix linter --------- Co-authored-by: Erno Hopearuoho --- .all-contributorsrc | 7 +++++++ README.md | 1 + lua/CopilotChat/health.lua | 6 ++++-- rplugin/python3/CopilotChat/__init__.py | 1 + rplugin/python3/{ => CopilotChat}/copilot.py | 6 +++--- .../copilot_plugin.py} | 6 +++--- .../{ => CopilotChat}/handlers/chat_handler.py | 8 ++++---- .../handlers/inplace_chat_handler.py | 12 ++++++------ .../handlers/vsplit_chat_handler.py | 6 +++--- .../{ => CopilotChat}/mypynvim/core/autocmdmapper.py | 2 +- .../{ => CopilotChat}/mypynvim/core/buffer.py | 2 +- .../{ => CopilotChat}/mypynvim/core/keymapper.py | 2 +- .../python3/{ => CopilotChat}/mypynvim/core/nvim.py | 8 ++++---- .../{ => CopilotChat}/mypynvim/core/window.py | 4 ++-- .../mypynvim/ui_components/calculator.py | 4 ++-- .../mypynvim/ui_components/layout.py | 8 ++++---- .../mypynvim/ui_components/popup.py | 12 ++++++------ .../mypynvim/ui_components/types.py | 0 rplugin/python3/{ => CopilotChat}/prompts.py | 0 rplugin/python3/{ => CopilotChat}/typings.py | 0 rplugin/python3/{ => CopilotChat}/utilities.py | 4 ++-- 21 files changed, 55 insertions(+), 44 deletions(-) create mode 100644 rplugin/python3/CopilotChat/__init__.py rename rplugin/python3/{ => CopilotChat}/copilot.py (98%) rename rplugin/python3/{copilot-plugin.py => CopilotChat/copilot_plugin.py} (92%) rename rplugin/python3/{ => CopilotChat}/handlers/chat_handler.py (97%) rename rplugin/python3/{ => CopilotChat}/handlers/inplace_chat_handler.py (97%) rename rplugin/python3/{ => CopilotChat}/handlers/vsplit_chat_handler.py (85%) rename rplugin/python3/{ => CopilotChat}/mypynvim/core/autocmdmapper.py (95%) rename rplugin/python3/{ => CopilotChat}/mypynvim/core/buffer.py (98%) rename rplugin/python3/{ => CopilotChat}/mypynvim/core/keymapper.py (95%) rename rplugin/python3/{ => CopilotChat}/mypynvim/core/nvim.py (92%) rename rplugin/python3/{ => CopilotChat}/mypynvim/core/window.py (88%) rename rplugin/python3/{ => CopilotChat}/mypynvim/ui_components/calculator.py (95%) rename rplugin/python3/{ => CopilotChat}/mypynvim/ui_components/layout.py (96%) rename rplugin/python3/{ => CopilotChat}/mypynvim/ui_components/popup.py (93%) rename rplugin/python3/{ => CopilotChat}/mypynvim/ui_components/types.py (100%) rename rplugin/python3/{ => CopilotChat}/prompts.py (100%) rename rplugin/python3/{ => CopilotChat}/typings.py (100%) rename rplugin/python3/{ => CopilotChat}/utilities.py (97%) diff --git a/.all-contributorsrc b/.all-contributorsrc index 6d3e511e..5b6a32b6 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -68,6 +68,13 @@ "profile": "https://github.com/ktns", "contributions": ["code"] }, + { + "login": "errnoh", + "name": "Erno Hopearuoho", + "avatar_url": "https://avatars.githubusercontent.com/u/373946?v=4", + "profile": "https://github.com/errnoh", + "contributions": ["code"] + }, { "login": "shaungarwood", "name": "Shaun Garwood", diff --git a/README.md b/README.md index d1ea7da0..7a81a74f 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d PostCyberPunk
PostCyberPunk

📖 Katsuhiko Nishimra
Katsuhiko Nishimra

💻 + Erno Hopearuoho
Erno Hopearuoho

💻 Shaun Garwood
Shaun Garwood

💻 diff --git a/lua/CopilotChat/health.lua b/lua/CopilotChat/health.lua index 09ca5b96..5893f812 100644 --- a/lua/CopilotChat/health.lua +++ b/lua/CopilotChat/health.lua @@ -53,7 +53,9 @@ function M.check() return end - file:write('import pynvim; print(pynvim.__version__)') + file:write( + 'import pynvim; v = pynvim.VERSION; print("{0}.{1}.{2}".format(v.major, v.minor, v.patch))' + ) file:close() -- Run the temporary Python script and capture the output @@ -67,7 +69,7 @@ function M.check() -- Delete the temporary Python script os.remove(temp_file) - if pynvim_version ~= '0.5.0' then + if vim.version.lt(pynvim_version, '0.4.3') then warn('pynvim version ' .. pynvim_version .. ' is not supported') else ok('pynvim version ' .. pynvim_version .. ' is supported') diff --git a/rplugin/python3/CopilotChat/__init__.py b/rplugin/python3/CopilotChat/__init__.py new file mode 100644 index 00000000..446ecc17 --- /dev/null +++ b/rplugin/python3/CopilotChat/__init__.py @@ -0,0 +1 @@ +from .copilot_plugin import CopilotPlugin as CopilotPlugin diff --git a/rplugin/python3/copilot.py b/rplugin/python3/CopilotChat/copilot.py similarity index 98% rename from rplugin/python3/copilot.py rename to rplugin/python3/CopilotChat/copilot.py index 25dbba67..23653fba 100644 --- a/rplugin/python3/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -5,10 +5,10 @@ from typing import Dict, List import dotenv -import prompts +import CopilotChat.prompts as prompts import requests -import typings -import utilities +import CopilotChat.typings as typings +import CopilotChat.utilities as utilities from prompt_toolkit import PromptSession from prompt_toolkit.history import InMemoryHistory diff --git a/rplugin/python3/copilot-plugin.py b/rplugin/python3/CopilotChat/copilot_plugin.py similarity index 92% rename from rplugin/python3/copilot-plugin.py rename to rplugin/python3/CopilotChat/copilot_plugin.py index ec9b4b5b..ee2a07a1 100644 --- a/rplugin/python3/copilot-plugin.py +++ b/rplugin/python3/CopilotChat/copilot_plugin.py @@ -1,7 +1,7 @@ import pynvim -from handlers.inplace_chat_handler import InPlaceChatHandler -from handlers.vsplit_chat_handler import VSplitChatHandler -from mypynvim.core.nvim import MyNvim +from CopilotChat.handlers.inplace_chat_handler import InPlaceChatHandler +from CopilotChat.handlers.vsplit_chat_handler import VSplitChatHandler +from CopilotChat.mypynvim.core.nvim import MyNvim PLUGIN_MAPPING_CMD = "CopilotChatMapping" PLUGIN_AUTOCMD_CMD = "CopilotChatAutocmd" diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/CopilotChat/handlers/chat_handler.py similarity index 97% rename from rplugin/python3/handlers/chat_handler.py rename to rplugin/python3/CopilotChat/handlers/chat_handler.py index e81cb2d8..357fc7b2 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/chat_handler.py @@ -3,10 +3,10 @@ from typing import Optional, cast import os -import prompts as system_prompts -from copilot import Copilot -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim +import CopilotChat.prompts as system_prompts +from CopilotChat.copilot import Copilot +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim def is_module_installed(name): diff --git a/rplugin/python3/handlers/inplace_chat_handler.py b/rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py similarity index 97% rename from rplugin/python3/handlers/inplace_chat_handler.py rename to rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py index dc5db6ac..ed938c30 100644 --- a/rplugin/python3/handlers/inplace_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py @@ -1,9 +1,9 @@ -import prompts as system_prompts -from handlers.chat_handler import ChatHandler -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim -from mypynvim.ui_components.layout import Box, Layout -from mypynvim.ui_components.popup import PopUp +import CopilotChat.prompts as system_prompts +from CopilotChat.handlers.chat_handler import ChatHandler +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.ui_components.layout import Box, Layout +from CopilotChat.mypynvim.ui_components.popup import PopUp # Define constants for the models MODEL_GPT4 = "gpt-4" diff --git a/rplugin/python3/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py similarity index 85% rename from rplugin/python3/handlers/vsplit_chat_handler.py rename to rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index 191fd6b2..6afc6add 100644 --- a/rplugin/python3/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -1,6 +1,6 @@ -from handlers.chat_handler import ChatHandler -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim +from CopilotChat.handlers.chat_handler import ChatHandler +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim class VSplitChatHandler(ChatHandler): diff --git a/rplugin/python3/mypynvim/core/autocmdmapper.py b/rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py similarity index 95% rename from rplugin/python3/mypynvim/core/autocmdmapper.py rename to rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py index 7ba731b8..3bb152fb 100644 --- a/rplugin/python3/mypynvim/core/autocmdmapper.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, Callable, Union if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class AutocmdMapper: diff --git a/rplugin/python3/mypynvim/core/buffer.py b/rplugin/python3/CopilotChat/mypynvim/core/buffer.py similarity index 98% rename from rplugin/python3/mypynvim/core/buffer.py rename to rplugin/python3/CopilotChat/mypynvim/core/buffer.py index c11db7f7..983709bb 100644 --- a/rplugin/python3/mypynvim/core/buffer.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/buffer.py @@ -5,7 +5,7 @@ from pynvim.api import Buffer if TYPE_CHECKING: - from .nvim import MyNvim + from Copilotchat.mypynvim.core.nvim import MyNvim class MyBuffer(Buffer): diff --git a/rplugin/python3/mypynvim/core/keymapper.py b/rplugin/python3/CopilotChat/mypynvim/core/keymapper.py similarity index 95% rename from rplugin/python3/mypynvim/core/keymapper.py rename to rplugin/python3/CopilotChat/mypynvim/core/keymapper.py index 4c93ee6c..2a111d4e 100644 --- a/rplugin/python3/mypynvim/core/keymapper.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/keymapper.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, Callable, Union if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class Keymapper: diff --git a/rplugin/python3/mypynvim/core/nvim.py b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py similarity index 92% rename from rplugin/python3/mypynvim/core/nvim.py rename to rplugin/python3/CopilotChat/mypynvim/core/nvim.py index 4eeba15d..8a70fdce 100644 --- a/rplugin/python3/mypynvim/core/nvim.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py @@ -3,10 +3,10 @@ from pynvim import Nvim from pynvim.api.nvim import Current -from .autocmdmapper import AutocmdMapper -from .buffer import MyBuffer -from .keymapper import Keymapper -from .window import MyWindow +from CopilotChat.mypynvim.core.autocmdmapper import AutocmdMapper +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.keymapper import Keymapper +from CopilotChat.mypynvim.core.window import MyWindow class MyNvim(Nvim): diff --git a/rplugin/python3/mypynvim/core/window.py b/rplugin/python3/CopilotChat/mypynvim/core/window.py similarity index 88% rename from rplugin/python3/mypynvim/core/window.py rename to rplugin/python3/CopilotChat/mypynvim/core/window.py index 0aadfc4f..f5c23aa1 100644 --- a/rplugin/python3/mypynvim/core/window.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/window.py @@ -4,10 +4,10 @@ from pynvim.api import Window -from .buffer import MyBuffer +from CopilotChat.mypynvim.core.buffer import MyBuffer if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class MyWindow(Window): diff --git a/rplugin/python3/mypynvim/ui_components/calculator.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py similarity index 95% rename from rplugin/python3/mypynvim/ui_components/calculator.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py index 1f19d4ab..ac6ecaa7 100644 --- a/rplugin/python3/mypynvim/ui_components/calculator.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py @@ -3,10 +3,10 @@ from dataclasses import dataclass from typing import TYPE_CHECKING, Literal, Union -from mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.core.nvim import MyNvim if TYPE_CHECKING: - from .popup import PopUpConfiguration + from CopilotChat.mypynvim.ui_components.popup import PopUpConfiguration @dataclass diff --git a/rplugin/python3/mypynvim/ui_components/layout.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py similarity index 96% rename from rplugin/python3/mypynvim/ui_components/layout.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py index dfea8c87..13fa1222 100644 --- a/rplugin/python3/mypynvim/ui_components/layout.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py @@ -1,11 +1,11 @@ from dataclasses import dataclass from typing import Callable, Literal, Optional, Union, cast -from mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.core.nvim import MyNvim -from .calculator import Calculator -from .popup import PopUp -from .types import PopUpConfiguration, Relative +from CopilotChat.mypynvim.ui_components.calculator import Calculator +from CopilotChat.mypynvim.ui_components.popup import PopUp +from CopilotChat.mypynvim.ui_components.types import PopUpConfiguration, Relative class Box: diff --git a/rplugin/python3/mypynvim/ui_components/popup.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py similarity index 93% rename from rplugin/python3/mypynvim/ui_components/popup.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py index cab2bac9..e5a63d9b 100644 --- a/rplugin/python3/mypynvim/ui_components/popup.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py @@ -5,16 +5,16 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Union if TYPE_CHECKING: - from mypynvim.core.nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim - from .layout import Layout + from CopilotChat.mypynvim.ui_components.layout import Layout -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.window import MyWindow +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.window import MyWindow -from .calculator import Calculator -from .types import PaddingKeys, PopUpConfiguration, Relative +from CopilotChat.mypynvim.ui_components.calculator import Calculator +from CopilotChat.mypynvim.ui_components.types import PaddingKeys, PopUpConfiguration, Relative @dataclass diff --git a/rplugin/python3/mypynvim/ui_components/types.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/types.py similarity index 100% rename from rplugin/python3/mypynvim/ui_components/types.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/types.py diff --git a/rplugin/python3/prompts.py b/rplugin/python3/CopilotChat/prompts.py similarity index 100% rename from rplugin/python3/prompts.py rename to rplugin/python3/CopilotChat/prompts.py diff --git a/rplugin/python3/typings.py b/rplugin/python3/CopilotChat/typings.py similarity index 100% rename from rplugin/python3/typings.py rename to rplugin/python3/CopilotChat/typings.py diff --git a/rplugin/python3/utilities.py b/rplugin/python3/CopilotChat/utilities.py similarity index 97% rename from rplugin/python3/utilities.py rename to rplugin/python3/CopilotChat/utilities.py index bc0540a7..fbc418e3 100644 --- a/rplugin/python3/utilities.py +++ b/rplugin/python3/CopilotChat/utilities.py @@ -2,8 +2,8 @@ import os import random -import prompts -import typings +import CopilotChat.prompts as prompts +import CopilotChat.typings as typings def random_hex(length: int = 65): From 287add8a37b5ee9ed694aaeeaccd74793b3cb6f6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 13 Feb 2024 15:35:27 +0000 Subject: [PATCH 58/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 83145d03..6f4ae0de 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -348,7 +348,7 @@ CONTRIBUTORS ✨ *CopilotChat-copilot-chat-for-neovim-contributors-✨* Thanks goes to these wonderful people (emoji key ): -gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖Katsuhiko Nishimra💻Shaun Garwood💻This project follows the all-contributors +gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖Katsuhiko Nishimra💻Erno Hopearuoho💻Shaun Garwood💻This project follows the all-contributors specification. Contributions of any kind are welcome! From 9d9f4019f7f7e12479d4e2bb921db5ace7b5f222 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 23:38:22 +0800 Subject: [PATCH 59/68] chore(main): release 1.2.0 (#47) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ version.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 271c534c..180b68e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.2.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-13) + + +### Features + +* restructure for pynvim 0.4.3 backwards compatibility ([#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45)) ([52350c7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/52350c78dbcfcb3acabf3478276ad9a87ebbfd26)) + ## [1.1.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.1...v1.1.0) (2024-02-10) diff --git a/version.txt b/version.txt index 9084fa2f..26aaba0e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.1.0 +1.2.0 From fc3206cccbb27c25ad000111e308d37c8295143d Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Tue, 13 Feb 2024 23:52:07 +0800 Subject: [PATCH 60/68] chore: fix all contributors setup --- .all-contributorsrc | 2 +- README.md | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 5b6a32b6..fc6bbd7e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -88,5 +88,5 @@ "repoType": "github", "repoHost": "https://github.com", "projectName": "CopilotChat.nvim", - "projectOwner": "jellydn" + "projectOwner": "CopilotC-Nvim" } diff --git a/README.md b/README.md index 7a81a74f..f3a86e9c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-) @@ -314,19 +314,19 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d - - - - - - - + + + + + + + - - - - + + + +
gptlang
gptlang

💻 📖
Dung Duc Huynh (Kaka)
Dung Duc Huynh (Kaka)

💻 📖
Ahmed Haracic
Ahmed Haracic

💻
Trí Thiện Nguyễn
Trí Thiện Nguyễn

💻
He Zhizhou
He Zhizhou

💻
Guruprakash Rajakkannu
Guruprakash Rajakkannu

💻
kristofka
kristofka

💻
gptlang
gptlang

💻 📖
Dung Duc Huynh (Kaka)
Dung Duc Huynh (Kaka)

💻 📖
Ahmed Haracic
Ahmed Haracic

💻
Trí Thiện Nguyễn
Trí Thiện Nguyễn

💻
He Zhizhou
He Zhizhou

💻
Guruprakash Rajakkannu
Guruprakash Rajakkannu

💻
kristofka
kristofka

💻
PostCyberPunk
PostCyberPunk

📖
Katsuhiko Nishimra
Katsuhiko Nishimra

💻
Erno Hopearuoho
Erno Hopearuoho

💻
Shaun Garwood
Shaun Garwood

💻
PostCyberPunk
PostCyberPunk

📖
Katsuhiko Nishimra
Katsuhiko Nishimra

💻
Erno Hopearuoho
Erno Hopearuoho

💻
Shaun Garwood
Shaun Garwood

💻
From 2ec21ef46a3333f881d4a55c7d3431b3fe61d8f8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 13 Feb 2024 15:52:34 +0000 Subject: [PATCH 61/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 6f4ae0de..697a9a51 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -360,7 +360,7 @@ STARGAZERS OVER TIME ~ ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square +1. *All Contributors*: https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square 2. *@jellydn*: 3. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif 4. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif From 0b13c6f5bf43d6ec1cdbc572b510a171986e5ed3 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Wed, 14 Feb 2024 17:29:29 +0800 Subject: [PATCH 62/68] docs: update remote plugin example path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3a86e9c..5a522b6d 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ For example: ```vim " python3 plugins -call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-plugin.py', [ +call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/CopilotChat', [ \ {'sync': v:false, 'name': 'CopilotChat', 'type': 'command', 'opts': {'nargs': '1'}}, \ {'sync': v:false, 'name': 'CopilotChatVisual', 'type': 'command', 'opts': {'nargs': '1', 'range': ''}}, \ {'sync': v:false, 'name': 'CopilotChatInPlace', 'type': 'command', 'opts': {'nargs': '*', 'range': ''}}, From 59931fde36e9ea4d966aab49587aa1bc9f71efd3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 14 Feb 2024 09:29:54 +0000 Subject: [PATCH 63/68] chore(doc): auto generate docs --- doc/CopilotChat.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 697a9a51..e6a327ea 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 13 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 14 ============================================================================== Table of Contents *CopilotChat-table-of-contents* @@ -86,7 +86,7 @@ For example: >vim " python3 plugins - call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-plugin.py', [ + call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/CopilotChat', [ \ {'sync': v:false, 'name': 'CopilotChat', 'type': 'command', 'opts': {'nargs': '1'}}, \ {'sync': v:false, 'name': 'CopilotChatVisual', 'type': 'command', 'opts': {'nargs': '1', 'range': ''}}, \ {'sync': v:false, 'name': 'CopilotChatInPlace', 'type': 'command', 'opts': {'nargs': '*', 'range': ''}}, From 528e6b4b33737e4863fccdb7ed2c6d7aec4f2029 Mon Sep 17 00:00:00 2001 From: gptlang Date: Wed, 14 Feb 2024 11:47:56 +0000 Subject: [PATCH 64/68] feat: CopilotChatReset command --- .pre-commit-config.yaml | 4 ---- CHANGELOG.md | 13 +++++-------- rplugin/python3/CopilotChat/copilot.py | 7 +++++-- rplugin/python3/CopilotChat/copilot_plugin.py | 5 +++++ .../python3/CopilotChat/handlers/chat_handler.py | 2 +- .../CopilotChat/handlers/vsplit_chat_handler.py | 3 ++- rplugin/python3/CopilotChat/mypynvim/core/nvim.py | 5 ++--- rplugin/python3/CopilotChat/mypynvim/core/window.py | 3 +-- .../CopilotChat/mypynvim/ui_components/layout.py | 1 - .../CopilotChat/mypynvim/ui_components/popup.py | 8 +++++--- 10 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93e78079..b83089ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,10 +3,6 @@ repos: rev: "23.10.0" hooks: - id: black - - repo: https://github.com/PyCQA/isort - rev: "5.12.0" - hooks: - - id: isort - repo: https://github.com/PyCQA/flake8 rev: "6.1.0" hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index 180b68e7..8d461669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,24 +2,21 @@ ## [1.2.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-13) - ### Features -* restructure for pynvim 0.4.3 backwards compatibility ([#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45)) ([52350c7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/52350c78dbcfcb3acabf3478276ad9a87ebbfd26)) +- restructure for pynvim 0.4.3 backwards compatibility ([#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45)) ([52350c7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/52350c78dbcfcb3acabf3478276ad9a87ebbfd26)) ## [1.1.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.1...v1.1.0) (2024-02-10) - ### Features -* **chat_handler:** show extra info only once ([589a453](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/589a4538d648c8723d839ca963a47a6176be3c78)) -* Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) ([043e731](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/043e731005278649dbdf1d5866c6e3c7719f1202)) -* Proxy support ([19a8088](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/19a8088c171cb956fd553200b77c8dbbe76707b6)) - +- **chat_handler:** show extra info only once ([589a453](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/589a4538d648c8723d839ca963a47a6176be3c78)) +- Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) ([043e731](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/043e731005278649dbdf1d5866c6e3c7719f1202)) +- Proxy support ([19a8088](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/19a8088c171cb956fd553200b77c8dbbe76707b6)) ### Bug Fixes -* Wacky indentation in readme ([c5bf963](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/c5bf963f4702a8a94aa97de2e6205796cb381ae5)) +- Wacky indentation in readme ([c5bf963](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/c5bf963f4702a8a94aa97de2e6205796cb381ae5)) ## [1.0.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.0...v1.0.1) (2024-02-08) diff --git a/rplugin/python3/CopilotChat/copilot.py b/rplugin/python3/CopilotChat/copilot.py index 23653fba..b07365c9 100644 --- a/rplugin/python3/CopilotChat/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -4,11 +4,11 @@ import uuid from typing import Dict, List -import dotenv import CopilotChat.prompts as prompts -import requests import CopilotChat.typings as typings import CopilotChat.utilities as utilities +import dotenv +import requests from prompt_toolkit import PromptSession from prompt_toolkit.history import InMemoryHistory @@ -90,6 +90,9 @@ def authenticate(self): self.token = self.session.get(url, headers=headers).json() + def reset(self): + self.chat_history = [] + def ask( self, system_prompt: str, diff --git a/rplugin/python3/CopilotChat/copilot_plugin.py b/rplugin/python3/CopilotChat/copilot_plugin.py index ee2a07a1..acc72763 100644 --- a/rplugin/python3/CopilotChat/copilot_plugin.py +++ b/rplugin/python3/CopilotChat/copilot_plugin.py @@ -28,6 +28,11 @@ def copilot_agent_cmd(self, args: list[str]): code = self.nvim.eval("getreg('\"')") self.vsplit_chat_handler.chat(args[0], file_type, code) + @pynvim.command("CopilotChatReset") + def copilot_agent_reset_cmd(self): + if self.vsplit_chat_handler: + self.vsplit_chat_handler.copilot.reset() + @pynvim.command("CopilotChatVisual", nargs="1", range="") def copilot_agent_visual_cmd(self, args: list[str], range: list[int]): self.init_vsplit_chat_handler() diff --git a/rplugin/python3/CopilotChat/handlers/chat_handler.py b/rplugin/python3/CopilotChat/handlers/chat_handler.py index 357fc7b2..07637cb8 100644 --- a/rplugin/python3/CopilotChat/handlers/chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/chat_handler.py @@ -1,7 +1,7 @@ +import os import time from datetime import datetime from typing import Optional, cast -import os import CopilotChat.prompts as system_prompts from CopilotChat.copilot import Copilot diff --git a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index 6afc6add..2017dbc9 100644 --- a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -1,3 +1,4 @@ +from CopilotChat.copilot import Copilot from CopilotChat.handlers.chat_handler import ChatHandler from CopilotChat.mypynvim.core.buffer import MyBuffer from CopilotChat.mypynvim.core.nvim import MyNvim @@ -6,7 +7,7 @@ class VSplitChatHandler(ChatHandler): def __init__(self, nvim: MyNvim): self.nvim: MyNvim = nvim - self.copilot = None + self.copilot: Copilot = None self.buffer: MyBuffer = MyBuffer.new( self.nvim, { diff --git a/rplugin/python3/CopilotChat/mypynvim/core/nvim.py b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py index 8a70fdce..36be4f8e 100644 --- a/rplugin/python3/CopilotChat/mypynvim/core/nvim.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py @@ -1,12 +1,11 @@ from typing import Iterable, Union -from pynvim import Nvim -from pynvim.api.nvim import Current - from CopilotChat.mypynvim.core.autocmdmapper import AutocmdMapper from CopilotChat.mypynvim.core.buffer import MyBuffer from CopilotChat.mypynvim.core.keymapper import Keymapper from CopilotChat.mypynvim.core.window import MyWindow +from pynvim import Nvim +from pynvim.api.nvim import Current class MyNvim(Nvim): diff --git a/rplugin/python3/CopilotChat/mypynvim/core/window.py b/rplugin/python3/CopilotChat/mypynvim/core/window.py index f5c23aa1..b9fb8e77 100644 --- a/rplugin/python3/CopilotChat/mypynvim/core/window.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/window.py @@ -2,9 +2,8 @@ from typing import TYPE_CHECKING -from pynvim.api import Window - from CopilotChat.mypynvim.core.buffer import MyBuffer +from pynvim.api import Window if TYPE_CHECKING: from CopilotChat.mypynvim.core.nvim import MyNvim diff --git a/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py index 13fa1222..c61ddda5 100644 --- a/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py @@ -2,7 +2,6 @@ from typing import Callable, Literal, Optional, Union, cast from CopilotChat.mypynvim.core.nvim import MyNvim - from CopilotChat.mypynvim.ui_components.calculator import Calculator from CopilotChat.mypynvim.ui_components.popup import PopUp from CopilotChat.mypynvim.ui_components.types import PopUpConfiguration, Relative diff --git a/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py index e5a63d9b..1f52cbe9 100644 --- a/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py @@ -9,12 +9,14 @@ from CopilotChat.mypynvim.ui_components.layout import Layout - from CopilotChat.mypynvim.core.buffer import MyBuffer from CopilotChat.mypynvim.core.window import MyWindow - from CopilotChat.mypynvim.ui_components.calculator import Calculator -from CopilotChat.mypynvim.ui_components.types import PaddingKeys, PopUpConfiguration, Relative +from CopilotChat.mypynvim.ui_components.types import ( + PaddingKeys, + PopUpConfiguration, + Relative, +) @dataclass From 62baa3cd4b52f5e08be9b4333c78c6626d3db467 Mon Sep 17 00:00:00 2001 From: gptlang Date: Wed, 14 Feb 2024 11:50:07 +0000 Subject: [PATCH 65/68] debug: Log errors to /tmp/copilot.log --- rplugin/python3/CopilotChat/copilot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rplugin/python3/CopilotChat/copilot.py b/rplugin/python3/CopilotChat/copilot.py index b07365c9..72649e14 100644 --- a/rplugin/python3/CopilotChat/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -127,6 +127,11 @@ def ask( 400: "The developer of this plugin has made a mistake. Please report this issue.", 419: "You have been rate limited. Please try again later.", } + # Log error to /tmp/copilot.log + with open("/tmp/copilot.log", "a") as f: + f.write(f"Error: {response.status_code}\n") + f.write(f"Request: {data}\n") + f.write(f"Response: {response.text}\n") raise Exception( error_messages.get( response.status_code, f"Unknown error: {response.status_code}" From 46bdf018069072a8a43c468ee1cede45536909a3 Mon Sep 17 00:00:00 2001 From: gptlang Date: Wed, 14 Feb 2024 11:58:12 +0000 Subject: [PATCH 66/68] fix: Include more info about refusal reason --- rplugin/python3/CopilotChat/copilot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rplugin/python3/CopilotChat/copilot.py b/rplugin/python3/CopilotChat/copilot.py index 72649e14..c03e7927 100644 --- a/rplugin/python3/CopilotChat/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -124,7 +124,7 @@ def ask( error_messages = { 401: "Unauthorized. Make sure you have access to Copilot Chat.", 500: "Internal server error. Please try again later.", - 400: "The developer of this plugin has made a mistake. Please report this issue.", + 400: "Your prompt has been rejected by Microsoft.", 419: "You have been rate limited. Please try again later.", } # Log error to /tmp/copilot.log @@ -132,6 +132,13 @@ def ask( f.write(f"Error: {response.status_code}\n") f.write(f"Request: {data}\n") f.write(f"Response: {response.text}\n") + + error_code = response.json().get("error", {}).get("code") + if error_code and error_messages.get(response.status_code): + error_messages[ + response.status_code + ] = f"{error_messages[response.status_code]}: {error_code}" + raise Exception( error_messages.get( response.status_code, f"Unknown error: {response.status_code}" From bf6d29f3bde05c8a2b0f127737af13cc6df73b9a Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Wed, 14 Feb 2024 21:26:34 +0800 Subject: [PATCH 67/68] feat: add reset buffer for CopilotChatReset command --- rplugin/python3/CopilotChat/copilot_plugin.py | 1 + rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/rplugin/python3/CopilotChat/copilot_plugin.py b/rplugin/python3/CopilotChat/copilot_plugin.py index acc72763..5e2708fc 100644 --- a/rplugin/python3/CopilotChat/copilot_plugin.py +++ b/rplugin/python3/CopilotChat/copilot_plugin.py @@ -32,6 +32,7 @@ def copilot_agent_cmd(self, args: list[str]): def copilot_agent_reset_cmd(self): if self.vsplit_chat_handler: self.vsplit_chat_handler.copilot.reset() + self.vsplit_chat_handler.reset_buffer() @pynvim.command("CopilotChatVisual", nargs="1", range="") def copilot_agent_visual_cmd(self, args: list[str], range: list[int]): diff --git a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index 2017dbc9..9cd76a82 100644 --- a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -37,3 +37,7 @@ def vsplit(self): def chat(self, prompt: str, filetype: str, code: str = ""): super().chat(prompt, filetype, code, self.nvim.current.window.handle) + + def reset_buffer(self): + """Reset the chat buffer.""" + self.buffer.clear() From 47a05876a642531fc6b7f6318f11398fdcb8ab3b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 19:22:17 +0800 Subject: [PATCH 68/68] chore(main): release 1.3.0 (#48) --- CHANGELOG.md | 13 +++++++++++++ version.txt | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d461669..7aa3208b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [1.3.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.2.0...v1.3.0) (2024-02-14) + + +### Features + +* add reset buffer for CopilotChatReset command ([bf6d29f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/bf6d29f3bde05c8a2b0f127737af13cc6df73b9a)) +* CopilotChatReset command ([528e6b4](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/528e6b4b33737e4863fccdb7ed2c6d7aec4f2029)) + + +### Bug Fixes + +* Include more info about refusal reason ([46bdf01](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/46bdf018069072a8a43c468ee1cede45536909a3)) + ## [1.2.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-13) ### Features diff --git a/version.txt b/version.txt index 26aaba0e..f0bb29e7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.2.0 +1.3.0