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) 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* 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 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"