@@ -23,17 +23,6 @@ function! s:Echo(msg) abort
2323 endif
2424endfunction
2525
26- function ! s: EditorConfiguration () abort
27- let filetypes = copy (s: filetype_defaults )
28- if type (get (g: , ' copilot_filetypes' )) == v: t_dict
29- call extend (filetypes, g: copilot_filetypes )
30- endif
31- return {
32- \ ' enableAutoCompletions' : empty (get (g: , ' copilot_enabled' , 1 )) ? v: false : v: true ,
33- \ ' disabledLanguages' : map (sort (keys (filter (filetypes, { k , v - > empty (v ) }))), { _, v - > {' languageId' : v }}),
34- \ }
35- endfunction
36-
3726function ! copilot#Init (... ) abort
3827 call copilot#util#Defer ({ - > exists (' s:client' ) || s: Start () })
3928endfunction
@@ -46,7 +35,7 @@ function! s:Start() abort
4635 if s: Running () || exists (' s:client.startup_error' )
4736 return
4837 endif
49- let s: client = copilot#client#New ({ ' editorConfiguration ' : s: EditorConfiguration ()} )
38+ let s: client = copilot#client#New ()
5039endfunction
5140
5241function ! s: Stop () abort
@@ -599,20 +588,8 @@ function! s:VerifySetup() abort
599588 return
600589 endif
601590
602- let status = copilot#Call (' checkStatus' , {})
603-
604- if ! has_key (status, ' user' )
605- echo ' Copilot: Not authenticated. Invoke :Copilot setup'
606- return
607- endif
608-
609- if status.status == # ' NoTelemetryConsent'
610- echo ' Copilot: Telemetry terms not accepted. Invoke :Copilot setup'
611- return
612- endif
613-
614- if status.status == # ' NotAuthorized'
615- echo " Copilot: You don't have access to GitHub Copilot. Sign up by visiting https://github.com/settings/copilot"
591+ if exists (' s:client.status.kind' ) && s: client .status.kind == # ' Error'
592+ echo ' Copilot: Error: ' . get (s: client .status, ' message' , ' unknown' )
616593 return
617594 endif
618595
@@ -624,11 +601,8 @@ function! s:commands.status(opts) abort
624601 return
625602 endif
626603
627- if exists (' s:client.status.status' ) && s: client .status.status = ~# ' Warning\|Error'
628- echo ' Copilot: ' . s: client .status.status
629- if ! empty (get (s: client .status, ' message' , ' ' ))
630- echon ' : ' . s: client .status.message
631- endif
604+ if exists (' s:client.status.kind' ) && s: client .status.kind == # ' Warning'
605+ echo ' Copilot: Warning: ' . get (s: client .status, ' message' , ' unknown' )
632606 return
633607 endif
634608
@@ -643,12 +617,7 @@ function! s:commands.status(opts) abort
643617endfunction
644618
645619function ! s: commands .signout (opts) abort
646- let status = copilot#Call (' checkStatus' , {' options' : {' localChecksOnly' : v: true }})
647- if has_key (status, ' user' )
648- echo ' Copilot: Signed out as GitHub user ' . status.user
649- else
650- echo ' Copilot: Not signed in'
651- endif
620+ echo ' Copilot: Signed out'
652621 call copilot#Call (' signOut' , {})
653622endfunction
654623
@@ -659,14 +628,7 @@ function! s:commands.setup(opts) abort
659628 return
660629 endif
661630
662- let browser = copilot#Browser ()
663-
664- let status = copilot#Call (' checkStatus' , {})
665- if has_key (status, ' user' )
666- let data = {' status' : ' AlreadySignedIn' , ' user' : status.user }
667- else
668- let data = copilot#Call (' signInInitiate' , {})
669- endif
631+ let data = copilot#Call (' signIn' , {})
670632
671633 if has_key (data, ' verificationUri' )
672634 let uri = data.verificationUri
@@ -688,24 +650,13 @@ function! s:commands.setup(opts) abort
688650 endif
689651 if get (a: opts , ' bang' )
690652 call s: Echo (codemsg . " In your browser, visit " . uri)
691- elseif len (browser)
692- call input (codemsg . " Press ENTER to open GitHub in your browser\n " )
693- let status = {}
694- call copilot#job#Stream (browser + [uri], v: null , v: null , function (' s:BrowserCallback' , [status]))
695- let time = reltime ()
696- while empty (status) && reltimefloat (reltime (time)) < 5
697- sleep 10 m
698- endwhile
699- if get (status, ' code' , browser[0 ] !=# ' xdg-open' ) != 0
700- call s: Echo (" Failed to open browser. Visit " . uri)
701- else
702- call s: Echo (" Opened " . uri)
703- endif
653+ let request = copilot#Request (' signInConfirm' , {})
704654 else
705- call s: Echo (codemsg . " Could not find browser. Visit " . uri)
655+ call input (codemsg . " Press ENTER to open GitHub in your browser\n " )
656+ let request = copilot#Request (' workspace/executeCommand' , data.command )
706657 endif
707- call s: Echo (" Waiting (could take up to 10 seconds)" )
708- let request = copilot#Request ( ' signInConfirm ' , { ' userCode ' : data.userCode}) .Wait ()
658+ call s: Echo (" Waiting for " . data.userCode . " at " . uri . " (could take up to 10 seconds)" )
659+ call request.Wait ()
709660 finally
710661 if exists (' mouse' )
711662 let &mouse = mouse
@@ -768,16 +719,6 @@ function! s:commands.version(opts) abort
768719 call s: EditorVersionWarning ()
769720endfunction
770721
771- function ! s: UpdateEditorConfiguration () abort
772- try
773- if s: Running ()
774- call copilot#Notify (' notifyChangeConfiguration' , {' settings' : s: EditorConfiguration ()})
775- endif
776- catch
777- call copilot#logger#Exception ()
778- endtry
779- endfunction
780-
781722let s: feedback_url = ' https://github.com/orgs/community/discussions/categories/copilot'
782723function ! s: commands .feedback (opts) abort
783724 echo s: feedback_url
@@ -795,12 +736,10 @@ endfunction
795736
796737function ! s: commands .disable (opts) abort
797738 let g: copilot_enabled = 0
798- call s: UpdateEditorConfiguration ()
799739endfunction
800740
801741function ! s: commands .enable (opts) abort
802742 let g: copilot_enabled = 1
803- call s: UpdateEditorConfiguration ()
804743endfunction
805744
806745function ! s: commands .panel (opts) abort
0 commit comments