Skip to content

Commit b480c96

Browse files
authored
feat: restructure for pynvim 0.4.3 backwards compatibility
* move files under subdirectory * change to use local relative imports * fix healthcheck to support pynvim 0.4.3 and use correct python version * Fix imports again
1 parent a34b639 commit b480c96

19 files changed

Lines changed: 45 additions & 44 deletions

File tree

lua/CopilotChat/health.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function M.check()
5353
return
5454
end
5555

56-
file:write('import pynvim; print(pynvim.__version__)')
56+
file:write('import pynvim; v = pynvim.VERSION; print("{0}.{1}.{2}".format(v.major, v.minor, v.patch))')
5757
file:close()
5858

5959
-- Run the temporary Python script and capture the output
@@ -67,7 +67,7 @@ function M.check()
6767
-- Delete the temporary Python script
6868
os.remove(temp_file)
6969

70-
if pynvim_version ~= '0.5.0' then
70+
if vim.version.lt(pynvim_version, "0.4.3") then
7171
warn('pynvim version ' .. pynvim_version .. ' is not supported')
7272
else
7373
ok('pynvim version ' .. pynvim_version .. ' is supported')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .copilot_plugin import CopilotPlugin as CopilotPlugin
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from typing import Dict, List
66

77
import dotenv
8-
import prompts
8+
import CopilotChat.prompts as prompts
99
import requests
10-
import typings
11-
import utilities
10+
import CopilotChat.typings as typings
11+
import CopilotChat.utilities as utilities
1212
from prompt_toolkit import PromptSession
1313
from prompt_toolkit.history import InMemoryHistory
1414

rplugin/python3/copilot-plugin.py renamed to rplugin/python3/CopilotChat/copilot_plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pynvim
2-
from handlers.inplace_chat_handler import InPlaceChatHandler
3-
from handlers.vsplit_chat_handler import VSplitChatHandler
4-
from mypynvim.core.nvim import MyNvim
2+
from CopilotChat.handlers.inplace_chat_handler import InPlaceChatHandler
3+
from CopilotChat.handlers.vsplit_chat_handler import VSplitChatHandler
4+
from CopilotChat.mypynvim.core.nvim import MyNvim
55

66
PLUGIN_MAPPING_CMD = "CopilotChatMapping"
77
PLUGIN_AUTOCMD_CMD = "CopilotChatAutocmd"

rplugin/python3/handlers/chat_handler.py renamed to rplugin/python3/CopilotChat/handlers/chat_handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from typing import Optional, cast
44
import os
55

6-
import prompts as system_prompts
7-
from copilot import Copilot
8-
from mypynvim.core.buffer import MyBuffer
9-
from mypynvim.core.nvim import MyNvim
6+
import CopilotChat.prompts as system_prompts
7+
from CopilotChat.copilot import Copilot
8+
from CopilotChat.mypynvim.core.buffer import MyBuffer
9+
from CopilotChat.mypynvim.core.nvim import MyNvim
1010

1111

1212
def is_module_installed(name):

rplugin/python3/handlers/inplace_chat_handler.py renamed to rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import prompts as system_prompts
2-
from handlers.chat_handler import ChatHandler
3-
from mypynvim.core.buffer import MyBuffer
4-
from mypynvim.core.nvim import MyNvim
5-
from mypynvim.ui_components.layout import Box, Layout
6-
from mypynvim.ui_components.popup import PopUp
1+
import CopilotChat.prompts as system_prompts
2+
from CopilotChat.handlers.chat_handler import ChatHandler
3+
from CopilotChat.mypynvim.core.buffer import MyBuffer
4+
from CopilotChat.mypynvim.core.nvim import MyNvim
5+
from CopilotChat.mypynvim.ui_components.layout import Box, Layout
6+
from CopilotChat.mypynvim.ui_components.popup import PopUp
77

88
# Define constants for the models
99
MODEL_GPT4 = "gpt-4"

rplugin/python3/handlers/vsplit_chat_handler.py renamed to rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from handlers.chat_handler import ChatHandler
2-
from mypynvim.core.buffer import MyBuffer
3-
from mypynvim.core.nvim import MyNvim
1+
from CopilotChat.handlers.chat_handler import ChatHandler
2+
from CopilotChat.mypynvim.core.buffer import MyBuffer
3+
from CopilotChat.mypynvim.core.nvim import MyNvim
44

55

66
class VSplitChatHandler(ChatHandler):

rplugin/python3/mypynvim/core/autocmdmapper.py renamed to rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TYPE_CHECKING, Callable, Union
44

55
if TYPE_CHECKING:
6-
from .nvim import MyNvim
6+
from CopilotChat.mypynvim.core.nvim import MyNvim
77

88

99
class AutocmdMapper:

rplugin/python3/mypynvim/core/buffer.py renamed to rplugin/python3/CopilotChat/mypynvim/core/buffer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pynvim.api import Buffer
66

77
if TYPE_CHECKING:
8-
from .nvim import MyNvim
8+
from Copilotchat.mypynvim.core.nvim import MyNvim
99

1010

1111
class MyBuffer(Buffer):

rplugin/python3/mypynvim/core/keymapper.py renamed to rplugin/python3/CopilotChat/mypynvim/core/keymapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TYPE_CHECKING, Callable, Union
44

55
if TYPE_CHECKING:
6-
from .nvim import MyNvim
6+
from CopilotChat.mypynvim.core.nvim import MyNvim
77

88

99
class Keymapper:

0 commit comments

Comments
 (0)