From 89b6276e995de2e05ea391a9d1045676737c93bd Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Sat, 3 Feb 2024 22:42:58 +0800 Subject: [PATCH 01/43] feat: add CopilotChatDebugInfo command (#51) * feat: add CopilotChatDebugInfo command chore: add remote plugin path to util * docs: add debug command to receipts --- README.md | 6 ++++ cspell-tool.txt | 4 ++- lua/CopilotChat/init.lua | 62 +++++++++++++++++++++++++++++++++++++++ lua/CopilotChat/utils.lua | 19 ++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 46c6022c..71812b99 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,12 @@ For further reference, you can view @jellydn's [configuration](https://github.co ## Receipts +### Debugging with `:messages` and `:CopilotChatDebugInfo` + +If you encounter any issues, you can run the command `:messages` to inspect the log. You can also run the command `:CopilotChatDebugInfo` to inspect the debug information. + +[![Debug Info](https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif)](https://gyazo.com/bf00e700bcee1b77bcbf7b516b552521) + ### How to setup with `which-key.nvim` A special thanks to @ecosse3 for the configuration of [which-key](https://github.com/jellydn/CopilotChat.nvim/issues/30). diff --git a/cspell-tool.txt b/cspell-tool.txt index 73288a14..400bb5a2 100644 --- a/cspell-tool.txt +++ b/cspell-tool.txt @@ -65,4 +65,6 @@ noautocmd roleplay vusted luarocks -isort \ No newline at end of file +isort +checkhealth +sysname \ No newline at end of file diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index d3058d41..85510023 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -30,6 +30,68 @@ M.setup = function(options) end, { nargs = '*', range = true }) end + -- Show debug info + utils.create_cmd('CopilotChatDebugInfo', function() + -- Get the log file path + local log_file_path = utils.get_log_file_path() + + -- Get the rplugin path + local rplugin_path = utils.get_remote_plugins_path() + + -- Create a popup with the log file path + local lines = { + 'CopilotChat.nvim Info:', + '- Log file path: ' .. log_file_path, + '- Rplugin path: ' .. rplugin_path, + 'If you are facing issues, run `:checkhealth CopilotChat` and share the output.', + 'There is a common issue is "Ambiguous use of user-defined command". Please check the pin issues on the repository.', + 'Press `q` to close this window.', + 'Press `?` to open the rplugin file.', + } + + local width = 0 + for _, line in ipairs(lines) do + width = math.max(width, #line) + end + local height = #lines + local opts = { + relative = 'editor', + width = width + 4, + height = height + 2, + row = (vim.o.lines - height) / 2 - 1, + col = (vim.o.columns - width) / 2, + style = 'minimal', + border = 'rounded', + } + local bufnr = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines) + vim.api.nvim_open_win(bufnr, true, opts) + + -- Bind 'q' to close the window + vim.api.nvim_buf_set_keymap( + bufnr, + 'n', + 'q', + 'close', + { noremap = true, silent = true } + ) + + -- Bind `?` to open remote plugin detail + vim.api.nvim_buf_set_keymap( + bufnr, + 'n', + '?', + -- Close the current window and open the rplugin file + 'closeedit ' + .. rplugin_path + .. '', + { noremap = true, silent = true } + ) + end, { + nargs = '*', + range = true, + }) + utils.log_info( 'Execute ":UpdateRemotePlugins" and restart Neovim before starting a chat with Copilot.' ) diff --git a/lua/CopilotChat/utils.lua b/lua/CopilotChat/utils.lua index 3402d5b6..472c411e 100644 --- a/lua/CopilotChat/utils.lua +++ b/lua/CopilotChat/utils.lua @@ -2,6 +2,25 @@ local M = {} local log = require('CopilotChat.vlog') +--- Get the log file path +---@return string +M.get_log_file_path = function() + return log.get_log_file() +end + +-- The CopilotChat.nvim is built using remote plugins. +-- This is the path to the rplugin.vim file. +-- Refer https://neovim.io/doc/user/remote_plugin.html#%3AUpdateRemotePlugins +-- @return string +M.get_remote_plugins_path = function() + local os = vim.loop.os_uname().sysname + if os == 'Linux' or os == 'Darwin' then + return '~/.local/share/nvim/rplugin.vim' + elseif os == 'Windows' then + return '~/AppData/Local/nvim/rplugin.vim' + end +end + --- Create custom command ---@param cmd string The command name ---@param func function The function to execute From b50d85612d97e0c4713d45919dbeadcb747b9b53 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 3 Feb 2024 14:43:18 +0000 Subject: [PATCH 02/43] chore(doc): auto generate docs --- doc/CopilotChat.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 868a9f45..0b0b8f22 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -202,6 +202,15 @@ IN-PLACE CHAT POPUP ~ RECEIPTS *CopilotChat-copilot-chat-for-neovim-receipts* +DEBUGGING WITH :MESSAGES AND :COPILOTCHATDEBUGINFO ~ + +If you encounter any issues, you can run the command `:messages` to inspect the +log. You can also run the command `:CopilotChatDebugInfo` to inspect the debug +information. + + + + HOW TO SETUP WITH WHICH-KEY.NVIM ~ A special thanks to @ecosse3 for the configuration of which-key @@ -314,7 +323,8 @@ Contributions of any kind welcome! 5. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif 6. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif 7. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif -8. *@ecosse3*: +8. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif +9. *@ecosse3*: Generated by panvimdoc From 0d4c217723b020241c19c9213b9a6c8dd0b8875f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 15:24:23 +0800 Subject: [PATCH 03/43] chore(main): release 1.1.0 (#52) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d0ab5b9..e5dba741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [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) From ca6321cb257ed4f38ec9848712fd559639f2df33 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 4 Feb 2024 07:24:46 +0000 Subject: [PATCH 04/43] 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 0b0b8f22..1ff3f1bd 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,4 +1,4 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 03 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 04 ============================================================================== Table of Contents *CopilotChat-table-of-contents* From b8d0a9d0e0824ff3b643a2652202be2a51b37dbc Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Sun, 4 Feb 2024 15:29:58 +0800 Subject: [PATCH 05/43] feat: show date time and additional information on end separator (#53) * feat: show date time and addition information on end separator * refactor: merge system prompts to one file --- rplugin/python3/handlers/chat_handler.py | 32 ++++++++++++------- .../python3/handlers/inplace_chat_handler.py | 6 ++-- rplugin/python3/handlers/prompts.py | 2 -- rplugin/python3/prompts.py | 2 ++ 4 files changed, 24 insertions(+), 18 deletions(-) delete mode 100644 rplugin/python3/handlers/prompts.py diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/handlers/chat_handler.py index ebcdfac6..75f1a3d7 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/handlers/chat_handler.py @@ -1,6 +1,7 @@ +from datetime import datetime from typing import Optional, cast -import prompts as prompts +import prompts as system_prompts from copilot import Copilot from mypynvim.core.buffer import MyBuffer from mypynvim.core.nvim import MyNvim @@ -52,18 +53,18 @@ def chat( self.nvim.exec_lua('require("CopilotChat.spinner").hide()') if not disable_end_separator: - self._add_end_separator() + self._add_end_separator(model) # private def _construct_system_prompt(self, prompt: str): - system_prompt = prompts.COPILOT_INSTRUCTIONS - if prompt == prompts.FIX_SHORTCUT: - system_prompt = prompts.COPILOT_FIX - elif prompt == prompts.TEST_SHORTCUT: - system_prompt = prompts.COPILOT_TESTS - elif prompt == prompts.EXPLAIN_SHORTCUT: - system_prompt = prompts.COPILOT_EXPLAIN + system_prompt = system_prompts.COPILOT_INSTRUCTIONS + if prompt == system_prompts.FIX_SHORTCUT: + system_prompt = system_prompts.COPILOT_FIX + elif prompt == system_prompts.TEST_SHORTCUT: + system_prompt = system_prompts.COPILOT_TESTS + elif prompt == system_prompts.EXPLAIN_SHORTCUT: + system_prompt = system_prompts.COPILOT_EXPLAIN return system_prompt def _add_start_separator( @@ -204,6 +205,13 @@ def _add_chat_messages( token.split("\n"), ) - def _add_end_separator(self): - end_separator = "\n---\n" - self.buffer.append(end_separator.split("\n")) + def _add_end_separator(self, model: str): + 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" + + end_message = model_info + additional_instructions + disclaimer + 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 d3b36dc2..f0d784f2 100644 --- a/rplugin/python3/handlers/inplace_chat_handler.py +++ b/rplugin/python3/handlers/inplace_chat_handler.py @@ -5,8 +5,6 @@ from mypynvim.ui_components.layout import Box, Layout from mypynvim.ui_components.popup import PopUp -from . import prompts - # Define constants for the models MODEL_GPT4 = "gpt-4" MODEL_GPT35_TURBO = "gpt-3.5-turbo" @@ -243,10 +241,10 @@ def _set_keymaps(self): self.prompt_popup.map("n", "", lambda cb=self._toggle_system_model: cb()) self.prompt_popup.map( - "n", "'", lambda: self._set_prompt(prompts.PROMPT_SIMPLE_DOCSTRING) + "n", "'", lambda: self._set_prompt(system_prompts.PROMPT_SIMPLE_DOCSTRING) ) self.prompt_popup.map( - "n", "s", lambda: self._set_prompt(prompts.PROMPT_SEPARATE) + "n", "s", lambda: self._set_prompt(system_prompts.PROMPT_SEPARATE) ) self.prompt_popup.map( diff --git a/rplugin/python3/handlers/prompts.py b/rplugin/python3/handlers/prompts.py deleted file mode 100644 index f12db7c7..00000000 --- a/rplugin/python3/handlers/prompts.py +++ /dev/null @@ -1,2 +0,0 @@ -PROMPT_SIMPLE_DOCSTRING = "add simple docstring to this code" -PROMPT_SEPARATE = "add comments separating the code into sections" diff --git a/rplugin/python3/prompts.py b/rplugin/python3/prompts.py index 34a857a4..1290cbb0 100644 --- a/rplugin/python3/prompts.py +++ b/rplugin/python3/prompts.py @@ -247,3 +247,5 @@ Your code output should keep the same level of indentation as the user's code. You MUST add whitespace in the beginning of each line as needed to match the user's code. """ +PROMPT_SIMPLE_DOCSTRING = "add simple docstring to this code" +PROMPT_SEPARATE = "add comments separating the code into sections" From 0b917f633eaef621d293f344965e9e0545be9a80 Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Sun, 4 Feb 2024 15:42:27 +0800 Subject: [PATCH 06/43] fix: handle get remote plugin path on Windows --- lua/CopilotChat/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/CopilotChat/utils.lua b/lua/CopilotChat/utils.lua index 472c411e..3d83bdc3 100644 --- a/lua/CopilotChat/utils.lua +++ b/lua/CopilotChat/utils.lua @@ -16,7 +16,7 @@ M.get_remote_plugins_path = function() local os = vim.loop.os_uname().sysname if os == 'Linux' or os == 'Darwin' then return '~/.local/share/nvim/rplugin.vim' - elseif os == 'Windows' then + else return '~/AppData/Local/nvim/rplugin.vim' end end From 07cb1de2e225744fb74f6cc46fccadcd1df8466a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 15:59:45 +0800 Subject: [PATCH 07/43] chore(main): release 1.2.0 (#54) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5dba741..3c095c00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [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) 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 08/43] 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 09/43] 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 10/43] 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 11/43] 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 12/43] 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 13/43] 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 14/43] 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 15/43] 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 16/43] 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 17/43] 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 18/43] 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 19/43] 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 20/43] 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 21/43] 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 22/43] 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 23/43] 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 24/43] 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 25/43] 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 26/43] 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 27/43] 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 28/43] 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 29/43] 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 30/43] 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 31/43] 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 32/43] 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 33/43] 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 34/43] 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 35/43] 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 36/43] 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 37/43] 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 38/43] 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 39/43] 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 40/43] 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 41/43] 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 42/43] 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 43/43] 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