diff --git a/lua/CopilotChat/health.lua b/lua/CopilotChat/health.lua index 09ca5b96..d329ef4c 100644 --- a/lua/CopilotChat/health.lua +++ b/lua/CopilotChat/health.lua @@ -53,7 +53,7 @@ function M.check() return end - file:write('import pynvim; print(pynvim.__version__)') + file:write('import pynvim; v = pynvim.VERSION; print("{0}.{1}.{2}".format(v.major, v.minor, v.patch))') file:close() -- Run the temporary Python script and capture the output @@ -67,7 +67,7 @@ function M.check() -- Delete the temporary Python script os.remove(temp_file) - if pynvim_version ~= '0.5.0' then + if vim.version.lt(pynvim_version, "0.4.3") then warn('pynvim version ' .. pynvim_version .. ' is not supported') else ok('pynvim version ' .. pynvim_version .. ' is supported') diff --git a/rplugin/python3/CopilotChat/__init__.py b/rplugin/python3/CopilotChat/__init__.py new file mode 100644 index 00000000..446ecc17 --- /dev/null +++ b/rplugin/python3/CopilotChat/__init__.py @@ -0,0 +1 @@ +from .copilot_plugin import CopilotPlugin as CopilotPlugin diff --git a/rplugin/python3/copilot.py b/rplugin/python3/CopilotChat/copilot.py similarity index 98% rename from rplugin/python3/copilot.py rename to rplugin/python3/CopilotChat/copilot.py index 25dbba67..23653fba 100644 --- a/rplugin/python3/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -5,10 +5,10 @@ from typing import Dict, List import dotenv -import prompts +import CopilotChat.prompts as prompts import requests -import typings -import utilities +import CopilotChat.typings as typings +import CopilotChat.utilities as utilities from prompt_toolkit import PromptSession from prompt_toolkit.history import InMemoryHistory diff --git a/rplugin/python3/copilot-plugin.py b/rplugin/python3/CopilotChat/copilot_plugin.py similarity index 92% rename from rplugin/python3/copilot-plugin.py rename to rplugin/python3/CopilotChat/copilot_plugin.py index ec9b4b5b..ee2a07a1 100644 --- a/rplugin/python3/copilot-plugin.py +++ b/rplugin/python3/CopilotChat/copilot_plugin.py @@ -1,7 +1,7 @@ import pynvim -from handlers.inplace_chat_handler import InPlaceChatHandler -from handlers.vsplit_chat_handler import VSplitChatHandler -from mypynvim.core.nvim import MyNvim +from CopilotChat.handlers.inplace_chat_handler import InPlaceChatHandler +from CopilotChat.handlers.vsplit_chat_handler import VSplitChatHandler +from CopilotChat.mypynvim.core.nvim import MyNvim PLUGIN_MAPPING_CMD = "CopilotChatMapping" PLUGIN_AUTOCMD_CMD = "CopilotChatAutocmd" diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/CopilotChat/handlers/chat_handler.py similarity index 97% rename from rplugin/python3/handlers/chat_handler.py rename to rplugin/python3/CopilotChat/handlers/chat_handler.py index e81cb2d8..357fc7b2 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/chat_handler.py @@ -3,10 +3,10 @@ from typing import Optional, cast import os -import prompts as system_prompts -from copilot import Copilot -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim +import CopilotChat.prompts as system_prompts +from CopilotChat.copilot import Copilot +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim def is_module_installed(name): diff --git a/rplugin/python3/handlers/inplace_chat_handler.py b/rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py similarity index 97% rename from rplugin/python3/handlers/inplace_chat_handler.py rename to rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py index dc5db6ac..ed938c30 100644 --- a/rplugin/python3/handlers/inplace_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py @@ -1,9 +1,9 @@ -import prompts as system_prompts -from handlers.chat_handler import ChatHandler -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim -from mypynvim.ui_components.layout import Box, Layout -from mypynvim.ui_components.popup import PopUp +import CopilotChat.prompts as system_prompts +from CopilotChat.handlers.chat_handler import ChatHandler +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.ui_components.layout import Box, Layout +from CopilotChat.mypynvim.ui_components.popup import PopUp # Define constants for the models MODEL_GPT4 = "gpt-4" diff --git a/rplugin/python3/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py similarity index 85% rename from rplugin/python3/handlers/vsplit_chat_handler.py rename to rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index 191fd6b2..6afc6add 100644 --- a/rplugin/python3/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -1,6 +1,6 @@ -from handlers.chat_handler import ChatHandler -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim +from CopilotChat.handlers.chat_handler import ChatHandler +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim class VSplitChatHandler(ChatHandler): diff --git a/rplugin/python3/mypynvim/core/autocmdmapper.py b/rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py similarity index 95% rename from rplugin/python3/mypynvim/core/autocmdmapper.py rename to rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py index 7ba731b8..3bb152fb 100644 --- a/rplugin/python3/mypynvim/core/autocmdmapper.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, Callable, Union if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class AutocmdMapper: diff --git a/rplugin/python3/mypynvim/core/buffer.py b/rplugin/python3/CopilotChat/mypynvim/core/buffer.py similarity index 98% rename from rplugin/python3/mypynvim/core/buffer.py rename to rplugin/python3/CopilotChat/mypynvim/core/buffer.py index c11db7f7..983709bb 100644 --- a/rplugin/python3/mypynvim/core/buffer.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/buffer.py @@ -5,7 +5,7 @@ from pynvim.api import Buffer if TYPE_CHECKING: - from .nvim import MyNvim + from Copilotchat.mypynvim.core.nvim import MyNvim class MyBuffer(Buffer): diff --git a/rplugin/python3/mypynvim/core/keymapper.py b/rplugin/python3/CopilotChat/mypynvim/core/keymapper.py similarity index 95% rename from rplugin/python3/mypynvim/core/keymapper.py rename to rplugin/python3/CopilotChat/mypynvim/core/keymapper.py index 4c93ee6c..2a111d4e 100644 --- a/rplugin/python3/mypynvim/core/keymapper.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/keymapper.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, Callable, Union if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class Keymapper: diff --git a/rplugin/python3/mypynvim/core/nvim.py b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py similarity index 92% rename from rplugin/python3/mypynvim/core/nvim.py rename to rplugin/python3/CopilotChat/mypynvim/core/nvim.py index 4eeba15d..8a70fdce 100644 --- a/rplugin/python3/mypynvim/core/nvim.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py @@ -3,10 +3,10 @@ from pynvim import Nvim from pynvim.api.nvim import Current -from .autocmdmapper import AutocmdMapper -from .buffer import MyBuffer -from .keymapper import Keymapper -from .window import MyWindow +from CopilotChat.mypynvim.core.autocmdmapper import AutocmdMapper +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.keymapper import Keymapper +from CopilotChat.mypynvim.core.window import MyWindow class MyNvim(Nvim): diff --git a/rplugin/python3/mypynvim/core/window.py b/rplugin/python3/CopilotChat/mypynvim/core/window.py similarity index 88% rename from rplugin/python3/mypynvim/core/window.py rename to rplugin/python3/CopilotChat/mypynvim/core/window.py index 0aadfc4f..f5c23aa1 100644 --- a/rplugin/python3/mypynvim/core/window.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/window.py @@ -4,10 +4,10 @@ from pynvim.api import Window -from .buffer import MyBuffer +from CopilotChat.mypynvim.core.buffer import MyBuffer if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class MyWindow(Window): diff --git a/rplugin/python3/mypynvim/ui_components/calculator.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py similarity index 95% rename from rplugin/python3/mypynvim/ui_components/calculator.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py index 1f19d4ab..ac6ecaa7 100644 --- a/rplugin/python3/mypynvim/ui_components/calculator.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py @@ -3,10 +3,10 @@ from dataclasses import dataclass from typing import TYPE_CHECKING, Literal, Union -from mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.core.nvim import MyNvim if TYPE_CHECKING: - from .popup import PopUpConfiguration + from CopilotChat.mypynvim.ui_components.popup import PopUpConfiguration @dataclass diff --git a/rplugin/python3/mypynvim/ui_components/layout.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py similarity index 96% rename from rplugin/python3/mypynvim/ui_components/layout.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py index dfea8c87..13fa1222 100644 --- a/rplugin/python3/mypynvim/ui_components/layout.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py @@ -1,11 +1,11 @@ from dataclasses import dataclass from typing import Callable, Literal, Optional, Union, cast -from mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.core.nvim import MyNvim -from .calculator import Calculator -from .popup import PopUp -from .types import PopUpConfiguration, Relative +from CopilotChat.mypynvim.ui_components.calculator import Calculator +from CopilotChat.mypynvim.ui_components.popup import PopUp +from CopilotChat.mypynvim.ui_components.types import PopUpConfiguration, Relative class Box: diff --git a/rplugin/python3/mypynvim/ui_components/popup.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py similarity index 93% rename from rplugin/python3/mypynvim/ui_components/popup.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py index cab2bac9..e5a63d9b 100644 --- a/rplugin/python3/mypynvim/ui_components/popup.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py @@ -5,16 +5,16 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Union if TYPE_CHECKING: - from mypynvim.core.nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim - from .layout import Layout + from CopilotChat.mypynvim.ui_components.layout import Layout -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.window import MyWindow +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.window import MyWindow -from .calculator import Calculator -from .types import PaddingKeys, PopUpConfiguration, Relative +from CopilotChat.mypynvim.ui_components.calculator import Calculator +from CopilotChat.mypynvim.ui_components.types import PaddingKeys, PopUpConfiguration, Relative @dataclass diff --git a/rplugin/python3/mypynvim/ui_components/types.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/types.py similarity index 100% rename from rplugin/python3/mypynvim/ui_components/types.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/types.py diff --git a/rplugin/python3/prompts.py b/rplugin/python3/CopilotChat/prompts.py similarity index 100% rename from rplugin/python3/prompts.py rename to rplugin/python3/CopilotChat/prompts.py diff --git a/rplugin/python3/typings.py b/rplugin/python3/CopilotChat/typings.py similarity index 100% rename from rplugin/python3/typings.py rename to rplugin/python3/CopilotChat/typings.py diff --git a/rplugin/python3/utilities.py b/rplugin/python3/CopilotChat/utilities.py similarity index 97% rename from rplugin/python3/utilities.py rename to rplugin/python3/CopilotChat/utilities.py index bc0540a7..fbc418e3 100644 --- a/rplugin/python3/utilities.py +++ b/rplugin/python3/CopilotChat/utilities.py @@ -2,8 +2,8 @@ import os import random -import prompts -import typings +import CopilotChat.prompts as prompts +import CopilotChat.typings as typings def random_hex(length: int = 65):