@@ -23,17 +23,6 @@ function! s:Echo(msg) abort
23
23
endif
24
24
endfunction
25
25
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
-
37
26
function ! copilot#Init (... )abort
38
27
call copilot#util#Defer ({- >exists (' s:client' )|| s: Start () })
39
28
endfunction
@@ -46,7 +35,7 @@ function! s:Start() abort
46
35
if s: Running ()|| exists (' s:client.startup_error' )
47
36
return
48
37
endif
49
- let s: client= copilot#client#New ({ ' editorConfiguration ' : s: EditorConfiguration ()} )
38
+ let s: client= copilot#client#New ()
50
39
endfunction
51
40
52
41
function ! s: Stop ()abort
@@ -599,20 +588,8 @@ function! s:VerifySetup() abort
599
588
return
600
589
endif
601
590
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' )
616
593
return
617
594
endif
618
595
@@ -624,11 +601,8 @@ function! s:commands.status(opts) abort
624
601
return
625
602
endif
626
603
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' )
632
606
return
633
607
endif
634
608
@@ -643,12 +617,7 @@ function! s:commands.status(opts) abort
643
617
endfunction
644
618
645
619
function ! 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'
652
621
call copilot#Call (' signOut' , {})
653
622
endfunction
654
623
@@ -659,14 +628,7 @@ function! s:commands.setup(opts) abort
659
628
return
660
629
endif
661
630
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' , {})
670
632
671
633
if has_key (data,' verificationUri' )
672
634
let uri= data.verificationUri
@@ -688,24 +650,13 @@ function! s:commands.setup(opts) abort
688
650
endif
689
651
if get (a: opts ,' bang' )
690
652
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' , {})
704
654
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 )
706
657
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 (" Waitingfor " . data.userCode . " at " . uri . " (could take up to 10 seconds)" )
659
+ call request.Wait ()
709
660
finally
710
661
if exists (' mouse' )
711
662
let &mouse = mouse
@@ -768,16 +719,6 @@ function! s:commands.version(opts) abort
768
719
call s: EditorVersionWarning ()
769
720
endfunction
770
721
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
-
781
722
let s: feedback_url= ' https://github.com/orgs/community/discussions/categories/copilot'
782
723
function ! s: commands .feedback (opts)abort
783
724
echo s: feedback_url
@@ -795,12 +736,10 @@ endfunction
795
736
796
737
function ! s: commands .disable (opts)abort
797
738
let g: copilot_enabled= 0
798
- call s: UpdateEditorConfiguration ()
799
739
endfunction
800
740
801
741
function ! s: commands .enable (opts)abort
802
742
let g: copilot_enabled= 1
803
- call s: UpdateEditorConfiguration ()
804
743
endfunction
805
744
806
745
function ! s: commands .panel (opts)abort