diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93e78079..b83089ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,10 +3,6 @@ repos: rev: "23.10.0" hooks: - id: black - - repo: https://github.com/PyCQA/isort - rev: "5.12.0" - hooks: - - id: isort - repo: https://github.com/PyCQA/flake8 rev: "6.1.0" hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index 180b68e7..8d461669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,24 +2,21 @@ ## [1.2.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-13) - ### Features -* restructure for pynvim 0.4.3 backwards compatibility ([#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45)) ([52350c7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/52350c78dbcfcb3acabf3478276ad9a87ebbfd26)) +- restructure for pynvim 0.4.3 backwards compatibility ([#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45)) ([52350c7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/52350c78dbcfcb3acabf3478276ad9a87ebbfd26)) ## [1.1.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.1...v1.1.0) (2024-02-10) - ### Features -* **chat_handler:** show extra info only once ([589a453](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/589a4538d648c8723d839ca963a47a6176be3c78)) -* Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) ([043e731](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/043e731005278649dbdf1d5866c6e3c7719f1202)) -* Proxy support ([19a8088](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/19a8088c171cb956fd553200b77c8dbbe76707b6)) - +- **chat_handler:** show extra info only once ([589a453](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/589a4538d648c8723d839ca963a47a6176be3c78)) +- Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) ([043e731](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/043e731005278649dbdf1d5866c6e3c7719f1202)) +- Proxy support ([19a8088](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/19a8088c171cb956fd553200b77c8dbbe76707b6)) ### Bug Fixes -* Wacky indentation in readme ([c5bf963](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/c5bf963f4702a8a94aa97de2e6205796cb381ae5)) +- Wacky indentation in readme ([c5bf963](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/c5bf963f4702a8a94aa97de2e6205796cb381ae5)) ## [1.0.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.0...v1.0.1) (2024-02-08) diff --git a/rplugin/python3/CopilotChat/copilot.py b/rplugin/python3/CopilotChat/copilot.py index 23653fba..b07365c9 100644 --- a/rplugin/python3/CopilotChat/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -4,11 +4,11 @@ import uuid from typing import Dict, List -import dotenv import CopilotChat.prompts as prompts -import requests import CopilotChat.typings as typings import CopilotChat.utilities as utilities +import dotenv +import requests from prompt_toolkit import PromptSession from prompt_toolkit.history import InMemoryHistory @@ -90,6 +90,9 @@ def authenticate(self): self.token = self.session.get(url, headers=headers).json() + def reset(self): + self.chat_history = [] + def ask( self, system_prompt: str, diff --git a/rplugin/python3/CopilotChat/copilot_plugin.py b/rplugin/python3/CopilotChat/copilot_plugin.py index ee2a07a1..acc72763 100644 --- a/rplugin/python3/CopilotChat/copilot_plugin.py +++ b/rplugin/python3/CopilotChat/copilot_plugin.py @@ -28,6 +28,11 @@ def copilot_agent_cmd(self, args: list[str]): code = self.nvim.eval("getreg('\"')") self.vsplit_chat_handler.chat(args[0], file_type, code) + @pynvim.command("CopilotChatReset") + def copilot_agent_reset_cmd(self): + if self.vsplit_chat_handler: + self.vsplit_chat_handler.copilot.reset() + @pynvim.command("CopilotChatVisual", nargs="1", range="") def copilot_agent_visual_cmd(self, args: list[str], range: list[int]): self.init_vsplit_chat_handler() diff --git a/rplugin/python3/CopilotChat/handlers/chat_handler.py b/rplugin/python3/CopilotChat/handlers/chat_handler.py index 357fc7b2..07637cb8 100644 --- a/rplugin/python3/CopilotChat/handlers/chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/chat_handler.py @@ -1,7 +1,7 @@ +import os import time from datetime import datetime from typing import Optional, cast -import os import CopilotChat.prompts as system_prompts from CopilotChat.copilot import Copilot diff --git a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index 6afc6add..2017dbc9 100644 --- a/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -1,3 +1,4 @@ +from CopilotChat.copilot import Copilot from CopilotChat.handlers.chat_handler import ChatHandler from CopilotChat.mypynvim.core.buffer import MyBuffer from CopilotChat.mypynvim.core.nvim import MyNvim @@ -6,7 +7,7 @@ class VSplitChatHandler(ChatHandler): def __init__(self, nvim: MyNvim): self.nvim: MyNvim = nvim - self.copilot = None + self.copilot: Copilot = None self.buffer: MyBuffer = MyBuffer.new( self.nvim, { diff --git a/rplugin/python3/CopilotChat/mypynvim/core/nvim.py b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py index 8a70fdce..36be4f8e 100644 --- a/rplugin/python3/CopilotChat/mypynvim/core/nvim.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py @@ -1,12 +1,11 @@ from typing import Iterable, Union -from pynvim import Nvim -from pynvim.api.nvim import Current - from CopilotChat.mypynvim.core.autocmdmapper import AutocmdMapper from CopilotChat.mypynvim.core.buffer import MyBuffer from CopilotChat.mypynvim.core.keymapper import Keymapper from CopilotChat.mypynvim.core.window import MyWindow +from pynvim import Nvim +from pynvim.api.nvim import Current class MyNvim(Nvim): diff --git a/rplugin/python3/CopilotChat/mypynvim/core/window.py b/rplugin/python3/CopilotChat/mypynvim/core/window.py index f5c23aa1..b9fb8e77 100644 --- a/rplugin/python3/CopilotChat/mypynvim/core/window.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/window.py @@ -2,9 +2,8 @@ from typing import TYPE_CHECKING -from pynvim.api import Window - from CopilotChat.mypynvim.core.buffer import MyBuffer +from pynvim.api import Window if TYPE_CHECKING: from CopilotChat.mypynvim.core.nvim import MyNvim diff --git a/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py index 13fa1222..c61ddda5 100644 --- a/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py @@ -2,7 +2,6 @@ from typing import Callable, Literal, Optional, Union, cast from CopilotChat.mypynvim.core.nvim import MyNvim - from CopilotChat.mypynvim.ui_components.calculator import Calculator from CopilotChat.mypynvim.ui_components.popup import PopUp from CopilotChat.mypynvim.ui_components.types import PopUpConfiguration, Relative diff --git a/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py index e5a63d9b..1f52cbe9 100644 --- a/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py @@ -9,12 +9,14 @@ from CopilotChat.mypynvim.ui_components.layout import Layout - from CopilotChat.mypynvim.core.buffer import MyBuffer from CopilotChat.mypynvim.core.window import MyWindow - from CopilotChat.mypynvim.ui_components.calculator import Calculator -from CopilotChat.mypynvim.ui_components.types import PaddingKeys, PopUpConfiguration, Relative +from CopilotChat.mypynvim.ui_components.types import ( + PaddingKeys, + PopUpConfiguration, + Relative, +) @dataclass