From 9b19d51deacdf5c958933e99a2e75ebe4c968a9b Mon Sep 17 00:00:00 2001 From: Huynh Duc Dung Date: Fri, 15 Dec 2023 23:21:44 +0800 Subject: [PATCH] feat: set filetype to markdown and text wrapping --- rplugin/python3/plugin.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rplugin/python3/plugin.py b/rplugin/python3/plugin.py index 1113497..1629813 100644 --- a/rplugin/python3/plugin.py +++ b/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() @@ -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 @@ -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):