From 71162a9eb1ab942d33a4281d20e0b4fb3f39780d Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Fri, 23 Feb 2024 21:44:25 +0800 Subject: [PATCH 01/35] docs: add quick chat with your buffer tip --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index cb99195f..9f208a4d 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,24 @@ For further reference, you can view @jellydn's [configuration](https://github.co ## Tips +### Quick chat with your buffer + +To chat with Copilot using the entire content of the buffer, you can add the following configuration to your keymap: + +```lua + -- Quick chat with Copilot + { + "ccq", + function() + local input = vim.fn.input("Quick Chat: ") + if input ~= "" then + vim.cmd("CopilotChatBuffer " .. input) + end + end, + desc = "CopilotChat - Quick chat", + }, +``` + ### Integration with `telescope.nvim` To integrate CopilotChat with Telescope, you can add the following configuration to your keymap: From 9bfb0b7f0c7595f04d6491053fe538dda70d32ed Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Feb 2024 13:45:08 +0000 Subject: [PATCH 02/35] chore(doc): auto generate docs --- doc/CopilotChat.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 75b15b3b..6c931c2d 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -313,6 +313,26 @@ CHAT WITH COPILOT WITH ALL CONTENTS OF INFOCUS BUFFER ~ TIPS *CopilotChat-copilot-chat-for-neovim-tips* +QUICK CHAT WITH YOUR BUFFER ~ + +To chat with Copilot using the entire content of the buffer, you can add the +following configuration to your keymap: + +>lua + -- Quick chat with Copilot + { + "ccq", + function() + local input = vim.fn.input("Quick Chat: ") + if input ~= "" then + vim.cmd("CopilotChatBuffer " .. input) + end + end, + desc = "CopilotChat - Quick chat", + }, +< + + INTEGRATION WITH TELESCOPE.NVIM ~ To integrate CopilotChat with Telescope, you can add the following From 93df47595d4f0b1cb011d9409fff09dee69f3a83 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Fri, 23 Feb 2024 23:00:18 +0800 Subject: [PATCH 03/35] chore: run pre-commit Close #71 --- rplugin/python3/CopilotChat/copilot.py | 15 ++++++--------- rplugin/python3/CopilotChat/copilot_plugin.py | 12 +++++------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/rplugin/python3/CopilotChat/copilot.py b/rplugin/python3/CopilotChat/copilot.py index d4945ab7..32d5f605 100644 --- a/rplugin/python3/CopilotChat/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -79,8 +79,7 @@ def poll_auth(self, device_code: str) -> bool: def authenticate(self): if self.github_token is None: raise Exception("No token found") - self.vscode_sessionid = str( - uuid.uuid4()) + str(round(time.time() * 1000)) + self.vscode_sessionid = str(uuid.uuid4()) + str(round(time.time() * 1000)) url = "https://api.github.com/copilot_internal/v2/token" headers = { "authorization": f"token {self.github_token}", @@ -148,8 +147,8 @@ def ask( raise Exception( error_messages.get( - response.status_code, f"Unknown error: { - response.status_code}" + response.status_code, + f"Unknown error: {response.status_code}", ) ) for line in response.iter_lines(): @@ -185,9 +184,8 @@ def _get_embeddings(self, inputs: list[typings.FileExtract]): if i + 18 > len(inputs): data = utilities.generate_embedding_request(inputs[i:]) else: - data = utilities.generate_embedding_request(inputs[i: i + 18]) - response = self.session.post( - url, headers=self._headers(), json=data).json() + data = utilities.generate_embedding_request(inputs[i : i + 18]) + response = self.session.post(url, headers=self._headers(), json=data).json() if "data" not in response: raise Exception(f"Error fetching embeddings: {response}") for embedding in response["data"]: @@ -220,8 +218,7 @@ def main(): copilot = Copilot(token) if copilot.github_token is None: req = copilot.request_auth() - print("Please visit", req["verification_uri"], - "and enter", req["user_code"]) + print("Please visit", req["verification_uri"], "and enter", req["user_code"]) while not copilot.poll_auth(req["device_code"]): time.sleep(req["interval"]) print("Successfully authenticated") diff --git a/rplugin/python3/CopilotChat/copilot_plugin.py b/rplugin/python3/CopilotChat/copilot_plugin.py index f7c0c3a1..46cfa007 100644 --- a/rplugin/python3/CopilotChat/copilot_plugin.py +++ b/rplugin/python3/CopilotChat/copilot_plugin.py @@ -10,8 +10,7 @@ @pynvim.plugin class CopilotPlugin(object): def __init__(self, nvim: pynvim.Nvim): - self.nvim: MyNvim = MyNvim( - nvim, PLUGIN_MAPPING_CMD, PLUGIN_AUTOCMD_CMD) + self.nvim: MyNvim = MyNvim(nvim, PLUGIN_MAPPING_CMD, PLUGIN_AUTOCMD_CMD) self.vsplit_chat_handler = None self.inplace_chat_handler = None @@ -30,7 +29,7 @@ def copilot_agent_buffer_cmd(self, args: list[str]): self.init_vsplit_chat_handler() current_buffer = self.nvim.current.buffer lines = current_buffer[:] - # Get code from the current infocus buffer + # Get code from the current in focus buffer code = "\n".join(lines) if self.vsplit_chat_handler: file_type = self.nvim.current.buffer.options["filetype"] @@ -58,7 +57,7 @@ def copilot_agent_visual_cmd(self, args: list[str], range: list[int]): self.init_vsplit_chat_handler() if self.vsplit_chat_handler: file_type = self.nvim.current.buffer.options["filetype"] - code_lines = self.nvim.current.buffer[range[0] - 1: range[1]] + code_lines = self.nvim.current.buffer[range[0] - 1 : range[1]] code = "\n".join(code_lines) self.vsplit_chat_handler.vsplit() self.vsplit_chat_handler.chat(args[0], file_type, code) @@ -83,8 +82,7 @@ def inplace_cmd(self, args: list[str], range: list[int]): self.init_inplace_chat_handler() if self.inplace_chat_handler: file_type = self.nvim.current.buffer.options["filetype"] - code_lines = self.nvim.current.buffer[range[0] - 1: range[1]] + code_lines = self.nvim.current.buffer[range[0] - 1 : range[1]] code = "\n".join(code_lines) user_buffer = self.nvim.current.buffer - self.inplace_chat_handler.mount( - code, file_type, range, user_buffer) + self.inplace_chat_handler.mount(code, file_type, range, user_buffer) From 713ca00ef29a56c4c132809f07ea49a63ca8d492 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Fri, 23 Feb 2024 23:23:53 +0800 Subject: [PATCH 04/35] ci: setup pre-commit action ci: fix pre-commit action revert: add CopilotPlugin back --- .github/workflows/pre-commit.yml | 14 ++++++++++++++ .prettierignore | 1 + rplugin/python3/CopilotChat/__init__.py | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .prettierignore diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..524f04fe --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,14 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.1 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..1b763b1b --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +CHANGELOG.md diff --git a/rplugin/python3/CopilotChat/__init__.py b/rplugin/python3/CopilotChat/__init__.py index 446ecc17..cd83906c 100644 --- a/rplugin/python3/CopilotChat/__init__.py +++ b/rplugin/python3/CopilotChat/__init__.py @@ -1 +1 @@ -from .copilot_plugin import CopilotPlugin as CopilotPlugin +from .copilot_plugin import CopilotPlugin as CopilotPlugin # noqa: F401 From 4c404b4968cd95a33298aad9781ab0605c4568d3 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Fri, 23 Feb 2024 23:24:48 +0800 Subject: [PATCH 05/35] docs: add quick chat demo --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9f208a4d..129d0524 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,8 @@ To chat with Copilot using the entire content of the buffer, you can add the fol }, ``` +[![Chat with buffer](https://i.gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0.gif)](https://gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0) + ### Integration with `telescope.nvim` To integrate CopilotChat with Telescope, you can add the following configuration to your keymap: From 1ecb24766a54ed35573cf29ae9f7930c47e16cc7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Feb 2024 15:25:13 +0000 Subject: [PATCH 06/35] chore(doc): auto generate docs --- doc/CopilotChat.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 6c931c2d..50415996 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -332,6 +332,8 @@ following configuration to your keymap: }, < + + INTEGRATION WITH TELESCOPE.NVIM ~ @@ -570,12 +572,13 @@ STARGAZERS OVER TIME ~ 9. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif 10. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif 11. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif -12. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif -13. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif -14. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png -15. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif -16. *@ecosse3*: -17. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg +12. *Chat with buffer*: https://i.gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0.gif +13. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif +14. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif +15. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png +16. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif +17. *@ecosse3*: +18. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg Generated by panvimdoc From 4d5bc49a7c2687951b7d6791e386f4265c2fb4f0 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Fri, 23 Feb 2024 23:43:42 +0800 Subject: [PATCH 07/35] docs: add badges --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 129d0524..34fc5235 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ +![Prerequisite](https://img.shields.io/badge/python-%3E%3D3.10-blue.svg) +[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](http://next-swagger-doc.productsway.com/) +[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/CopilotC-Nvim/CopilotChat.nvim/main.svg)](https://results.pre-commit.ci/latest/github/CopilotC-Nvim/CopilotChat.nvim/main) [![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-) From db3e9096997b3e318219fedfdb997cc739b15a87 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Feb 2024 15:44:04 +0000 Subject: [PATCH 08/35] chore(doc): auto generate docs --- doc/CopilotChat.txt | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 50415996..b7999037 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -16,6 +16,8 @@ Table of Contents *CopilotChat-table-of-contents* ============================================================================== 1. Copilot Chat for Neovim *CopilotChat-copilot-chat-for-neovim* + + |CopilotChat-| @@ -561,24 +563,27 @@ STARGAZERS OVER TIME ~ ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square -2. *@treyhunner*: -3. *@nekowasabi*: -4. *@jellydn*: -5. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif -6. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif -7. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif -8. *Fix diagnostic*: https://i.gyazo.com/4aff3fdbc5c3eee59cb68939546fa2be.gif -9. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif -10. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif -11. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif -12. *Chat with buffer*: https://i.gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0.gif -13. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif -14. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif -15. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png -16. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif -17. *@ecosse3*: -18. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg +1. *Prerequisite*: https://img.shields.io/badge/python-%3E%3D3.10-blue.svg +2. *Documentation*: https://img.shields.io/badge/documentation-yes-brightgreen.svg +3. *pre-commit.ci status*: https://results.pre-commit.ci/badge/github/CopilotC-Nvim/CopilotChat.nvim/main.svg +4. *All Contributors*: https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square +5. *@treyhunner*: +6. *@nekowasabi*: +7. *@jellydn*: +8. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif +9. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif +10. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif +11. *Fix diagnostic*: https://i.gyazo.com/4aff3fdbc5c3eee59cb68939546fa2be.gif +12. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif +13. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif +14. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif +15. *Chat with buffer*: https://i.gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0.gif +16. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif +17. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif +18. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png +19. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif +20. *@ecosse3*: +21. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg Generated by panvimdoc From b277dab593f73c43bef6088ae23c80c0ccc0d860 Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Sat, 24 Feb 2024 00:01:06 +0800 Subject: [PATCH 09/35] ci: add deploy-gh-pages.yml --- .github/workflows/deploy-gh-pages.yml | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/deploy-gh-pages.yml diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml new file mode 100644 index 00000000..007d254c --- /dev/null +++ b/.github/workflows/deploy-gh-pages.yml @@ -0,0 +1,50 @@ +name: Deploy Github Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./ + destination: ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From 9bf2eeb35573b05e7af49fc86e7119db34f3b62d Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sat, 24 Feb 2024 00:03:56 +0800 Subject: [PATCH 10/35] docs: add github page for documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34fc5235..cdd6ce96 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![Prerequisite](https://img.shields.io/badge/python-%3E%3D3.10-blue.svg) -[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](http://next-swagger-doc.productsway.com/) +[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](https://copilotc-nvim.github.io/CopilotChat.nvim/) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/CopilotC-Nvim/CopilotChat.nvim/main.svg)](https://results.pre-commit.ci/latest/github/CopilotC-Nvim/CopilotChat.nvim/main) [![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-) From 7ac1f34d29c199b66150b9f084225c1e1030a70c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Feb 2024 16:04:17 +0000 Subject: [PATCH 11/35] 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 b7999037..d0fa97ba 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -16,7 +16,7 @@ Table of Contents *CopilotChat-table-of-contents* ============================================================================== 1. Copilot Chat for Neovim *CopilotChat-copilot-chat-for-neovim* - + |CopilotChat-| From a0a5a2a9ae0edf79cdf05620fcead7d59575d306 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sat, 24 Feb 2024 07:34:36 +0800 Subject: [PATCH 12/35] fix: enable vim diagnostics after finish the conversation Closed #72 --- rplugin/python3/CopilotChat/handlers/chat_handler.py | 6 ++++++ rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rplugin/python3/CopilotChat/handlers/chat_handler.py b/rplugin/python3/CopilotChat/handlers/chat_handler.py index 3bc8788d..fdd4beed 100644 --- a/rplugin/python3/CopilotChat/handlers/chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/chat_handler.py @@ -44,6 +44,9 @@ def chat( disable_end_separator: bool = False, model: str = "gpt-4", ): + """Disable vim diagnostics on the chat buffer""" + self.nvim.command(":lua vim.diagnostic.disable()") + disable_separators = ( self.nvim.eval("g:copilot_chat_disable_separators") == "yes" ) @@ -330,6 +333,9 @@ def _add_chat_messages( 'require("CopilotChat.utils").log_info(...)', "Copilot answered" ) + """ Enable vim diagnostics on the chat buffer after the chat is complete """ + self.nvim.command(":lua vim.diagnostic.enable()") + 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}." diff --git a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index 1608c53a..3742d45a 100644 --- a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -37,9 +37,6 @@ def vsplit(self): ) self.nvim.current.window.vars[var_key] = True - """ Disable vim diagnostics on the chat buffer """ - self.nvim.command(":lua vim.diagnostic.disable()") - def toggle_vsplit(self): """Toggle vsplit chat window.""" var_key = "copilot_chat" From 7dc877196296d1f2515ea1c24d0e7d3d4cb8d3b4 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Sat, 24 Feb 2024 03:46:00 +0100 Subject: [PATCH 13/35] feat: Add support for clear_chat_on_new_prompt config option * Add support for clear_chat_on_new_prompt config option Closes #73 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- README.md | 1 + lua/CopilotChat/init.lua | 2 ++ rplugin/python3/CopilotChat/copilot_plugin.py | 1 - .../python3/CopilotChat/handlers/vsplit_chat_handler.py | 8 ++++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cdd6ce96..0bacc86d 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ You have the ability to tailor this plugin to your specific needs using the conf show_help = 'yes', -- Show help text for CopilotChatInPlace disable_extra_info = 'no', -- Disable extra information in the response hide_system_prompt = 'yes', -- Hide system prompts in the response + clear_chat_on_new_prompt = 'no', -- If yes then clear chat history on new prompt proxy = '', -- Proxies requests via https or socks prompts = { -- Set dynamic prompts for CopilotChat commands Explain = 'Explain how it works.', diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index bba15a1e..d0adfb5a 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -14,6 +14,7 @@ _COPILOT_CHAT_GLOBAL_CONFIG = {} -- - show_help: ('yes' | 'no') default: 'yes'. -- - disable_extra_info: ('yes' | 'no') default: 'yes'. -- - hide_system_prompt: ('yes' | 'no') default: 'yes'. +-- - clear_chat_on_new_prompt: ('yes' | 'no') default: 'no'. -- - proxy: (string?) default: ''. -- - language: (string?) default: ''. -- - temperature: (string?) default: '0.1'. Value between 0.0 and 1.0. @@ -23,6 +24,7 @@ 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_hide_system_prompt = options and options.hide_system_prompt or 'yes' + vim.g.copilot_chat_clear_chat_on_new_prompt = options and options.clear_chat_on_new_prompt or 'no' vim.g.copilot_chat_proxy = options and options.proxy or '' vim.g.copilot_chat_language = options and options.language or '' vim.g.copilot_chat_temperature = options and options.temperature or '0.1' diff --git a/rplugin/python3/CopilotChat/copilot_plugin.py b/rplugin/python3/CopilotChat/copilot_plugin.py index 46cfa007..d12ada86 100644 --- a/rplugin/python3/CopilotChat/copilot_plugin.py +++ b/rplugin/python3/CopilotChat/copilot_plugin.py @@ -49,7 +49,6 @@ def copilot_agent_cmd(self, args: list[str]): @pynvim.command("CopilotChatReset") 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="") diff --git a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index 3742d45a..d677d2f9 100644 --- a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -15,6 +15,9 @@ def __init__(self, nvim: MyNvim): }, ) self.language = self.nvim.eval("g:copilot_chat_language") + self.clear_chat_on_new_prompt = ( + self.nvim.eval("g:copilot_chat_clear_chat_on_new_prompt") == "yes" + ) def vsplit(self): self.buffer.option("filetype", "copilot-chat") @@ -52,9 +55,14 @@ def toggle_vsplit(self): self.buffer.option("filetype", "markdown") def chat(self, prompt: str, filetype: str, code: str = ""): + if self.clear_chat_on_new_prompt: + self.reset_buffer() + self.buffer.option("filetype", "markdown") super().chat(prompt, filetype, code, self.nvim.current.window.handle) def reset_buffer(self): """Reset the chat buffer.""" + if self.copilot: + self.copilot.reset() self.buffer.clear() From d6f64a60c6cbfe1e5e1c08fa54bdbbb1d45420a6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 24 Feb 2024 02:46:22 +0000 Subject: [PATCH 14/35] 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 d0fa97ba..6df71825 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 23 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 24 ============================================================================== Table of Contents *CopilotChat-table-of-contents* @@ -212,6 +212,7 @@ configuration options outlined below: show_help = 'yes', -- Show help text for CopilotChatInPlace disable_extra_info = 'no', -- Disable extra information in the response hide_system_prompt = 'yes', -- Hide system prompts in the response + clear_chat_on_new_prompt = 'no', -- If yes then clear chat history on new prompt proxy = '', -- Proxies requests via https or socks prompts = { -- Set dynamic prompts for CopilotChat commands Explain = 'Explain how it works.', From c4bd20e24667e56c8eed284a3f74b7551bd54b50 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sat, 24 Feb 2024 10:47:49 +0800 Subject: [PATCH 15/35] docs(contributors): add deathbeam to contributors list --- .all-contributorsrc | 7 +++++++ README.md | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index a09b7ebb..32f0e7c9 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -102,6 +102,13 @@ "avatar_url": "https://avatars.githubusercontent.com/u/3443378?v=4", "profile": "https://github.com/AdrielVelazquez", "contributions": ["code", "doc"] + }, + { + "login": "deathbeam", + "name": "Tomas Slusny", + "avatar_url": "https://avatars.githubusercontent.com/u/5115805?v=4", + "profile": "https://github.com/deathbeam", + "contributions": ["code", "doc"] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index 0bacc86d..531b108e 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,7 @@ -![Prerequisite](https://img.shields.io/badge/python-%3E%3D3.10-blue.svg) -[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](https://copilotc-nvim.github.io/CopilotChat.nvim/) -[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/CopilotC-Nvim/CopilotChat.nvim/main.svg)](https://results.pre-commit.ci/latest/github/CopilotC-Nvim/CopilotChat.nvim/main) -[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-) @@ -520,6 +517,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Jack Muratore
Jack Muratore

💻 Adriel Velazquez
Adriel Velazquez

💻 📖 + + Tomas Slusny
Tomas Slusny

💻 📖 + From bd4e78b0c41aae8ed1f3428e74c31a0c36471c98 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 24 Feb 2024 02:48:33 +0000 Subject: [PATCH 16/35] chore(doc): auto generate docs --- doc/CopilotChat.txt | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 6df71825..398079df 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -16,8 +16,6 @@ Table of Contents *CopilotChat-table-of-contents* ============================================================================== 1. Copilot Chat for Neovim *CopilotChat-copilot-chat-for-neovim* - - |CopilotChat-| @@ -552,7 +550,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💻Erno Hopearuoho💻Shaun Garwood💻neutrinoA4💻 📖Jack Muratore💻Adriel Velazquez💻 📖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💻neutrinoA4💻 📖Jack Muratore💻Adriel Velazquez💻 📖Tomas Slusny💻 📖This project follows the all-contributors specification. Contributions of any kind are welcome! @@ -564,27 +562,24 @@ STARGAZERS OVER TIME ~ ============================================================================== 2. Links *CopilotChat-links* -1. *Prerequisite*: https://img.shields.io/badge/python-%3E%3D3.10-blue.svg -2. *Documentation*: https://img.shields.io/badge/documentation-yes-brightgreen.svg -3. *pre-commit.ci status*: https://results.pre-commit.ci/badge/github/CopilotC-Nvim/CopilotChat.nvim/main.svg -4. *All Contributors*: https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square -5. *@treyhunner*: -6. *@nekowasabi*: -7. *@jellydn*: -8. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif -9. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif -10. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif -11. *Fix diagnostic*: https://i.gyazo.com/4aff3fdbc5c3eee59cb68939546fa2be.gif -12. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif -13. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif -14. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif -15. *Chat with buffer*: https://i.gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0.gif -16. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif -17. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif -18. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png -19. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif -20. *@ecosse3*: -21. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg +1. *All Contributors*: https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square +2. *@treyhunner*: +3. *@nekowasabi*: +4. *@jellydn*: +5. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif +6. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif +7. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif +8. *Fix diagnostic*: https://i.gyazo.com/4aff3fdbc5c3eee59cb68939546fa2be.gif +9. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif +10. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif +11. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif +12. *Chat with buffer*: https://i.gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0.gif +13. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif +14. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif +15. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png +16. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif +17. *@ecosse3*: +18. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg Generated by panvimdoc From 976bf12cbf18e89fb47d8f37c33cba4ba5a6c522 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sat, 24 Feb 2024 11:11:34 +0800 Subject: [PATCH 17/35] chore: add TODO for clear token count --- rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index d677d2f9..ccce3d3b 100644 --- a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -61,6 +61,7 @@ def chat(self, prompt: str, filetype: str, code: str = ""): self.buffer.option("filetype", "markdown") super().chat(prompt, filetype, code, self.nvim.current.window.handle) + # TODO:Clear the token count on reset def reset_buffer(self): """Reset the chat buffer.""" if self.copilot: From fe186b0342552f9078d8b993dd06a953680be4b1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 24 Feb 2024 11:13:23 +0800 Subject: [PATCH 18/35] chore(main): release 1.9.0 (#76) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 17 +++++++++++++++++ version.txt | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e73ac88..8b10796e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [1.9.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.8.0...v1.9.0) (2024-02-24) + + +### Features + +* Add support for clear_chat_on_new_prompt config option ([7dc8771](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/7dc877196296d1f2515ea1c24d0e7d3d4cb8d3b4)) + + +### Bug Fixes + +* enable vim diagnostics after finish the conversation ([a0a5a2a](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/a0a5a2a9ae0edf79cdf05620fcead7d59575d306)), closes [#72](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/72) + + +### Reverts + +* add CopilotPlugin back ([713ca00](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/713ca00ef29a56c4c132809f07ea49a63ca8d492)) + ## [1.8.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.7.1...v1.8.0) (2024-02-23) diff --git a/version.txt b/version.txt index 27f9cd32..f8e233b2 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.8.0 +1.9.0 From f11eec9d1c47ccd077fa634470ff7dc750a407f2 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sat, 24 Feb 2024 11:13:54 +0800 Subject: [PATCH 19/35] chore: remove pre-commit with pre-commit.ci --- .github/workflows/pre-commit.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml deleted file mode 100644 index 524f04fe..00000000 --- a/.github/workflows/pre-commit.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: pre-commit - -on: - pull_request: - push: - branches: [main] - -jobs: - pre-commit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - - uses: pre-commit/action@v3.0.1 From 83553698943aae71e33921d386a85361593c4787 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sat, 24 Feb 2024 11:44:55 +0800 Subject: [PATCH 20/35] docs: add badges back --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 531b108e..7a24bc74 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Copilot Chat for Neovim +![Prerequisite](https://img.shields.io/badge/python-%3E%3D3.10-blue.svg) +[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](https://copilotc-nvim.github.io/CopilotChat.nvim/) +[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/CopilotC-Nvim/CopilotChat.nvim/main.svg)](https://results.pre-commit.ci/latest/github/CopilotC-Nvim/CopilotChat.nvim/main) + [![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-) From aebe45d59376a571b07b414ba95cdc41855798f4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 24 Feb 2024 03:45:25 +0000 Subject: [PATCH 21/35] chore(doc): auto generate docs --- doc/CopilotChat.txt | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 398079df..90bb9601 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -16,6 +16,9 @@ Table of Contents *CopilotChat-table-of-contents* ============================================================================== 1. Copilot Chat for Neovim *CopilotChat-copilot-chat-for-neovim* + + + |CopilotChat-| @@ -562,24 +565,27 @@ STARGAZERS OVER TIME ~ ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square -2. *@treyhunner*: -3. *@nekowasabi*: -4. *@jellydn*: -5. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif -6. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif -7. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif -8. *Fix diagnostic*: https://i.gyazo.com/4aff3fdbc5c3eee59cb68939546fa2be.gif -9. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif -10. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif -11. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif -12. *Chat with buffer*: https://i.gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0.gif -13. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif -14. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif -15. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png -16. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif -17. *@ecosse3*: -18. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg +1. *Prerequisite*: https://img.shields.io/badge/python-%3E%3D3.10-blue.svg +2. *Documentation*: https://img.shields.io/badge/documentation-yes-brightgreen.svg +3. *pre-commit.ci status*: https://results.pre-commit.ci/badge/github/CopilotC-Nvim/CopilotChat.nvim/main.svg +4. *All Contributors*: https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square +5. *@treyhunner*: +6. *@nekowasabi*: +7. *@jellydn*: +8. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif +9. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif +10. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif +11. *Fix diagnostic*: https://i.gyazo.com/4aff3fdbc5c3eee59cb68939546fa2be.gif +12. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif +13. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif +14. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif +15. *Chat with buffer*: https://i.gyazo.com/9b8cbf1d78a19f326282a6520bc9aab0.gif +16. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif +17. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif +18. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png +19. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif +20. *@ecosse3*: +21. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg Generated by panvimdoc From 14b428360da918ae3d6a7663f4c25d1a7194440d Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sun, 25 Feb 2024 00:08:34 +0800 Subject: [PATCH 22/35] chore(pre-commit): update versions of black, flake8, and prettier --- .pre-commit-config.yaml | 6 +++--- rplugin/python3/CopilotChat/copilot.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b83089ed..1f9f6923 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,13 @@ repos: - repo: https://github.com/psf/black - rev: "23.10.0" + rev: "24.2.0" hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: "6.1.0" + rev: "7.0.0" hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-prettier - rev: "fc260393cc4ec09f8fc0a5ba4437f481c8b55dc1" + rev: "v4.0.0-alpha.8" hooks: - id: prettier diff --git a/rplugin/python3/CopilotChat/copilot.py b/rplugin/python3/CopilotChat/copilot.py index 32d5f605..eb79e135 100644 --- a/rplugin/python3/CopilotChat/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -141,9 +141,9 @@ def ask( 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}" + error_messages[response.status_code] = ( + f"{error_messages[response.status_code]}: {error_code}" + ) raise Exception( error_messages.get( From 88f7b8b5f85a8fa0ecdb2f6c7a64a7f8f8e76743 Mon Sep 17 00:00:00 2001 From: Nisal <30633436+nisalVD@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:03:49 +1100 Subject: [PATCH 23/35] docs: input for items with args (#79) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7a24bc74..b227dac9 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ return { end, event = "VeryLazy", keys = { - { "ccb", "CopilotChatBuffer", desc = "CopilotChat - Chat with current buffer" }, + { "ccb", "CopilotChatBuffer ", desc = "CopilotChat - Chat with current buffer" }, { "cce", "CopilotChatExplain", desc = "CopilotChat - Explain code" }, { "cct", "CopilotChatTests", desc = "CopilotChat - Generate tests" }, { @@ -63,7 +63,7 @@ return { }, { "ccv", - ":CopilotChatVisual", + ":CopilotChatVisual ", mode = "x", desc = "CopilotChat - Open in vertical split", }, From d10759fe1a48864fccad9280e247d46a0456b177 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 26 Feb 2024 02:04:07 +0000 Subject: [PATCH 24/35] chore(doc): auto generate docs --- doc/CopilotChat.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 90bb9601..e7219ba0 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 24 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 26 ============================================================================== Table of Contents *CopilotChat-table-of-contents* @@ -71,7 +71,7 @@ LAZY.NVIM ~ end, event = "VeryLazy", keys = { - { "ccb", "CopilotChatBuffer", desc = "CopilotChat - Chat with current buffer" }, + { "ccb", "CopilotChatBuffer ", desc = "CopilotChat - Chat with current buffer" }, { "cce", "CopilotChatExplain", desc = "CopilotChat - Explain code" }, { "cct", "CopilotChatTests", desc = "CopilotChat - Generate tests" }, { @@ -81,7 +81,7 @@ LAZY.NVIM ~ }, { "ccv", - ":CopilotChatVisual", + ":CopilotChatVisual ", mode = "x", desc = "CopilotChat - Open in vertical split", }, From 4248f51a1c8ad6a426aa9c3118420e0292ef2890 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:05:09 +0800 Subject: [PATCH 25/35] docs: add nisalVD as a contributor for doc (#80) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .all-contributorsrc | 7 +++++++ README.md | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 32f0e7c9..49348a58 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -109,6 +109,13 @@ "avatar_url": "https://avatars.githubusercontent.com/u/5115805?v=4", "profile": "https://github.com/deathbeam", "contributions": ["code", "doc"] + }, + { + "login": "nisalVD", + "name": "Nisal", + "avatar_url": "https://avatars.githubusercontent.com/u/30633436?v=4", + "profile": "http://nisalvd.netlify.com/", + "contributions": ["doc"] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index b227dac9..cc8beaeb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors-) @@ -523,6 +523,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Tomas Slusny
Tomas Slusny

💻 📖 + Nisal
Nisal

📖 From 090d9627cbf6fa115898f748991a3c72243af109 Mon Sep 17 00:00:00 2001 From: gptlang Date: Mon, 26 Feb 2024 15:59:14 +0000 Subject: [PATCH 26/35] fix: raise error when auth fails to get token Closed #81 --- rplugin/python3/CopilotChat/copilot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rplugin/python3/CopilotChat/copilot.py b/rplugin/python3/CopilotChat/copilot.py index eb79e135..2723c5dd 100644 --- a/rplugin/python3/CopilotChat/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -89,6 +89,8 @@ def authenticate(self): } self.token = self.session.get(url, headers=headers).json() + if not self.token.get("token"): + raise Exception(f"Failed to authenticate: {self.token}") def reset(self): self.chat_history = [] From 741d356feffe0783138d65e496c09fd1ec2c73f3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 26 Feb 2024 15:59:45 +0000 Subject: [PATCH 27/35] chore(doc): auto generate docs chore(doc): auto generate docs --- doc/CopilotChat.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index e7219ba0..a48110c5 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 26 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 27 ============================================================================== Table of Contents *CopilotChat-table-of-contents* @@ -553,7 +553,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💻Erno Hopearuoho💻Shaun Garwood💻neutrinoA4💻 📖Jack Muratore💻Adriel Velazquez💻 📖Tomas Slusny💻 📖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💻neutrinoA4💻 📖Jack Muratore💻Adriel Velazquez💻 📖Tomas Slusny💻 📖Nisal📖This project follows the all-contributors specification. Contributions of any kind are welcome! @@ -568,7 +568,7 @@ STARGAZERS OVER TIME ~ 1. *Prerequisite*: https://img.shields.io/badge/python-%3E%3D3.10-blue.svg 2. *Documentation*: https://img.shields.io/badge/documentation-yes-brightgreen.svg 3. *pre-commit.ci status*: https://results.pre-commit.ci/badge/github/CopilotC-Nvim/CopilotChat.nvim/main.svg -4. *All Contributors*: https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square +4. *All Contributors*: https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square 5. *@treyhunner*: 6. *@nekowasabi*: 7. *@jellydn*: From 5db944a349247757fd0bcf22ea90e76112529d8c Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Tue, 27 Feb 2024 20:30:47 +0800 Subject: [PATCH 28/35] fix(ci): upgrade release action v4 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0cc66fc..5ed69576 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: name: release runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v3 + - uses: google-github-actions/release-please-action@v4 id: release with: release-type: simple From 84484c1aaa11bad6ef129c329338b69302d7c563 Mon Sep 17 00:00:00 2001 From: Nisal <30633436+nisalVD@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:39:18 +1100 Subject: [PATCH 29/35] docs: fixed up incorrect syntax for CopilotChatBuffer (#88) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc8beaeb..948eb158 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ return { end, event = "VeryLazy", keys = { - { "ccb", "CopilotChatBuffer ", desc = "CopilotChat - Chat with current buffer" }, + { "ccb", ":CopilotChatBuffer ", desc = "CopilotChat - Chat with current buffer" }, { "cce", "CopilotChatExplain", desc = "CopilotChat - Explain code" }, { "cct", "CopilotChatTests", desc = "CopilotChat - Generate tests" }, { From 0773a851d4aec8bd1c1cf8e017031d425c754e1a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 28 Feb 2024 10:39:38 +0000 Subject: [PATCH 30/35] 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 a48110c5..3c0b45ef 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 27 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 28 ============================================================================== Table of Contents *CopilotChat-table-of-contents* @@ -71,7 +71,7 @@ LAZY.NVIM ~ end, event = "VeryLazy", keys = { - { "ccb", "CopilotChatBuffer ", desc = "CopilotChat - Chat with current buffer" }, + { "ccb", ":CopilotChatBuffer ", desc = "CopilotChat - Chat with current buffer" }, { "cce", "CopilotChatExplain", desc = "CopilotChat - Explain code" }, { "cct", "CopilotChatTests", desc = "CopilotChat - Generate tests" }, { From f6a5f38690fdaa647ee848610ee817c010c5bc7b Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Wed, 28 Feb 2024 19:06:30 +0800 Subject: [PATCH 31/35] docs: add announce --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 948eb158..115a205e 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ +> [!NOTE] +> We are excited to announce that we are currently migrating the plugin to fully Lua in the [canary](https://github.com/CopilotC-Nvim/CopilotChat.nvim/tree/canary) branch. + > [!NOTE] > A new command, `CopilotChatBuffer` has been added. It allows you to chat with Copilot using the entire content of the buffer. From b59c014df4fe09cdaa1ada170944bcfa1b00c82b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 28 Feb 2024 11:08:35 +0000 Subject: [PATCH 32/35] chore(doc): auto generate docs --- doc/CopilotChat.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 3c0b45ef..84da67f8 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -22,6 +22,10 @@ Table of Contents *CopilotChat-table-of-contents* |CopilotChat-| + [!NOTE] We are excited to announce that we are currently migrating the plugin + to fully Lua in the canary + branch. + [!NOTE] A new command, `CopilotChatBuffer` has been added. It allows you to chat with Copilot using the entire content of the buffer. From 3903ecb92d143ad44a9ed96b1abb65abdb2db0d6 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Wed, 28 Feb 2024 21:56:13 +0800 Subject: [PATCH 33/35] fix: check Python 3 provider check on health check Closed #84 --- lua/CopilotChat/health.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/CopilotChat/health.lua b/lua/CopilotChat/health.lua index 5893f812..227d76f9 100644 --- a/lua/CopilotChat/health.lua +++ b/lua/CopilotChat/health.lua @@ -31,6 +31,11 @@ end -- Add health check for python3 and pynvim function M.check() start('CopilotChat.nvim health check') + if vim.g.loaded_python3_provider == 0 then + warn('Python 3 provider is disabled. Please enable it to use CopilotChat.nvim') + return + end + local python_version = run_python_command('--version') if python_version == false then From a16d130b9ce79b8baaffc358f9ef6a4b4e31c74c Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Wed, 28 Feb 2024 22:10:36 +0800 Subject: [PATCH 34/35] chore(ci): only bump on release branch --- .github/workflows/release.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ed69576..822466c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,6 @@ on: push: branches: - release - pull_request: - branches: - - main - - release permissions: contents: write @@ -21,7 +17,6 @@ jobs: id: release with: release-type: simple - package-name: CopilotChat.nvim token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v3 - name: tag stable versions From 6a222a6e1228e362ba0e4a0eb14fc9977fafd98d Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Wed, 28 Feb 2024 22:10:57 +0800 Subject: [PATCH 35/35] chore: bump to v1.9.1 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index f8e233b2..9ab8337f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.9.0 +1.9.1