1- import pynvim
2- import copilot
3- import dotenv
41import os
52import time
63
4+ import copilot
5+ import dotenv
6+ import pynvim
7+
78dotenv .load_dotenv ()
89
910
@@ -15,12 +16,13 @@ def __init__(self, nvim: pynvim.Nvim):
1516 if self .copilot .github_token is None :
1617 req = self .copilot .request_auth ()
1718 self .nvim .out_write (
18- f"Please visit { req ['verification_uri' ]} and enter the code { req ['user_code' ]} \n " )
19+ f"Please visit { req ['verification_uri' ]} and enter the code { req ['user_code' ]} \n "
20+ )
1921 current_time = time .time ()
20- wait_until = current_time + req [' expires_in' ]
22+ wait_until = current_time + req [" expires_in" ]
2123 while self .copilot .github_token is None :
22- self .copilot .poll_auth (req [' device_code' ])
23- time .sleep (req [' interval' ])
24+ self .copilot .poll_auth (req [" device_code" ])
25+ time .sleep (req [" interval" ])
2426 if time .time () > wait_until :
2527 self .nvim .out_write ("Timed out waiting for authentication\n " )
2628 return
@@ -42,6 +44,9 @@ def copilotChat(self, args: list[str]):
4244 # Create a new scratch buffer to hold the chat
4345 self .nvim .command ("enew" )
4446 self .nvim .command ("setlocal buftype=nofile bufhidden=hide noswapfile" )
47+ # Set filetype as markdown and wrap
48+ self .nvim .command ("setlocal filetype=markdown" )
49+ self .nvim .command ("setlocal wrap" )
4550 if self .nvim .current .line != "" :
4651 self .nvim .command ("normal o" )
4752 for token in self .copilot .ask (prompt , code , language = file_type ):
0 commit comments