Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor restructure for pynvim 0.4.3 backwards compatibility #34

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/CopilotChat/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down
1 change: 1 addition & 0 deletions rplugin/python3/CopilotChat/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .copilot_plugin import CopilotPlugin as CopilotPlugin
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down