Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
feat: set filetype to markdown and text wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn committed Dec 15, 2023
1 parent 49fa6b8 commit 9b19d51
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions rplugin/python3/plugin.py
@@ -1,9 +1,10 @@
import pynvim
import copilot
import dotenv
import os
import time

import copilot
import dotenv
import pynvim

dotenv.load_dotenv()


Expand All @@ -15,12 +16,13 @@ def __init__(self, nvim: pynvim.Nvim):
if self.copilot.github_token is None:
req = self.copilot.request_auth()
self.nvim.out_write(
f"Please visit {req['verification_uri']} and enter the code {req['user_code']}\n")
f"Please visit {req['verification_uri']} and enter the code {req['user_code']}\n"
)
current_time = time.time()
wait_until = current_time + req['expires_in']
wait_until = current_time + req["expires_in"]
while self.copilot.github_token is None:
self.copilot.poll_auth(req['device_code'])
time.sleep(req['interval'])
self.copilot.poll_auth(req["device_code"])
time.sleep(req["interval"])
if time.time() > wait_until:
self.nvim.out_write("Timed out waiting for authentication\n")
return
Expand All @@ -42,6 +44,9 @@ def copilotChat(self, args: list[str]):
# Create a new scratch buffer to hold the chat
self.nvim.command("enew")
self.nvim.command("setlocal buftype=nofile bufhidden=hide noswapfile")
# Set filetype as markdown and wrap
self.nvim.command("setlocal filetype=markdown")
self.nvim.command("setlocal wrap")
if self.nvim.current.line != "":
self.nvim.command("normal o")
for token in self.copilot.ask(prompt, code, language=file_type):
Expand Down

0 comments on commit 9b19d51

Please sign in to comment.