forked from CopilotC-Nvim/CopilotChat.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.py
More file actions
33 lines (23 loc) · 908 Bytes
/
window.py
File metadata and controls
33 lines (23 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from __future__ import annotations
from typing import TYPE_CHECKING
from pynvim.api import Window
from CopilotChat.mypynvim.core.buffer import MyBuffer
if TYPE_CHECKING:
from CopilotChat.mypynvim.core.nvim import MyNvim
class MyWindow(Window):
def __init__(self, nvim: MyNvim, window: Window):
self.win: Window = window
self.nvim: MyNvim = nvim
def __getattr__(self, attr):
return getattr(self.win, attr)
def command(self, command: str):
full_command = f"call win_execute({self.win.handle}, '{command}')"
self.nvim.command(full_command)
@property
def buffer(self) -> MyBuffer:
return MyBuffer(
self.nvim, self.nvim.request("nvim_win_get_buf", self.win.handle)
)
@buffer.setter
def buffer(self, buffer: MyBuffer):
return self.nvim.request("nvim_win_set_buf", self.win.handle, buffer.handle)