Skip to content

Commit cd7f010

Browse files
committed
Copilot.vim 1.42.0
1 parent 8703812 commit cd7f010

15 files changed

+527
-563
lines changed

README.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
# GitHub Copilot for Vim and Neovim
22

3-
GitHub Copilot uses OpenAI Codex to suggest code and entire functions in
4-
real-time right from your editor. Trained on billions of lines of public
5-
code, GitHub Copilot turns natural language prompts including comments and
6-
method names into coding suggestions across dozens of languages.
3+
GitHub Copilot is an AI pair programmer tool that helps you write code faster
4+
and smarter. Trained on billions of lines of public code, GitHub Copilot turns
5+
natural language prompts including comments and method names into coding
6+
suggestions across dozens of languages.
77

88
Copilot.vim is a Vim/Neovim plugin for GitHub Copilot.
99

1010
To learn more, visit
1111
[https://github.com/features/copilot](https://github.com/features/copilot).
1212

13-
## Subscription
13+
## Getting access to GitHub Copilot
1414

15-
GitHub Copilot requires a subscription. It is free for verified students and
16-
maintainers of popular open source projects on GitHub.
17-
18-
GitHub Copilot is subject to the [GitHub Additional Product
19-
Terms](https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features).
15+
To access GitHub Copilot, an active GitHub Copilot subscription is required.
16+
Sign up for [GitHub Copilot Free](https://github.com/settings/copilot), or
17+
request access from your enterprise admin.
2018

2119
## Getting started
2220

autoload/copilot.vim

+12-73
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ function! s:Echo(msg) abort
2323
endif
2424
endfunction
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-
3726
function! copilot#Init(...) abort
3827
call copilot#util#Defer({ -> exists('s:client') || s:Start() })
3928
endfunction
@@ -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()
5039
endfunction
5140

5241
function! 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
643617
endfunction
644618

645619
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'
652621
call copilot#Call('signOut', {})
653622
endfunction
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 10m
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()
769720
endfunction
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-
781722
let s:feedback_url = 'https://github.com/orgs/community/discussions/categories/copilot'
782723
function! s:commands.feedback(opts) abort
783724
echo s:feedback_url
@@ -795,12 +736,10 @@ endfunction
795736

796737
function! s:commands.disable(opts) abort
797738
let g:copilot_enabled = 0
798-
call s:UpdateEditorConfiguration()
799739
endfunction
800740

801741
function! s:commands.enable(opts) abort
802742
let g:copilot_enabled = 1
803-
call s:UpdateEditorConfiguration()
804743
endfunction
805744

806745
function! s:commands.panel(opts) abort

autoload/copilot/client.vim

+8-6
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,10 @@ function! copilot#client#Settings() abort
550550
let settings.http.proxy = 'http://' . settings.http.proxy
551551
endif
552552
if type(get(g:, 'copilot_settings')) == v:t_dict
553-
call extend(settings, g:copilot_settings)
553+
let settings.github = {'copilot': g:copilot_settings}
554+
endif
555+
if type(get(g:, 'copilot_lsp_settings')) == v:t_dict
556+
call extend(settings, g:copilot_lsp_settings)
554557
endif
555558
return settings
556559
endfunction
@@ -610,7 +613,7 @@ endfunction
610613
let s:notifications = {
611614
\ '$/progress': function('s:Progress'),
612615
\ 'featureFlagsNotification': function('s:Nop'),
613-
\ 'statusNotification': function('s:StatusNotification'),
616+
\ 'didChangeStatus': function('s:StatusNotification'),
614617
\ 'window/logMessage': function('copilot#handlers#window_logMessage'),
615618
\ }
616619

@@ -624,8 +627,8 @@ let s:vim_capabilities = {
624627
\ 'window': {'showDocument': {'support': v:true}},
625628
\ }
626629

627-
function! copilot#client#New(...) abort
628-
let opts = a:0 ? a:1 : {}
630+
function! copilot#client#New() abort
631+
let opts = {}
629632
let instance = {'requests': {},
630633
\ 'progress': {},
631634
\ 'workspaceFolders': {},
@@ -651,13 +654,12 @@ function! copilot#client#New(...) abort
651654
endif
652655
let instance.node = node
653656
let command = node + argv
654-
let opts = {}
655657
let opts.initializationOptions = {
656658
\ 'editorInfo': copilot#client#EditorInfo(),
657659
\ 'editorPluginInfo': copilot#client#EditorPluginInfo(),
658660
\ }
659661
let opts.workspaceFolders = []
660-
let settings = extend(copilot#client#Settings(), get(opts, 'editorConfiguration', {}))
662+
let settings = copilot#client#Settings()
661663
if type(get(g:, 'copilot_workspace_folders')) == v:t_list
662664
for folder in g:copilot_workspace_folders
663665
if type(folder) == v:t_string && !empty(folder) && folder !~# '\*\*\|^/$'

autoload/copilot/panel.vim

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ function! copilot#panel#Accept(...) abort
108108
endfunction
109109

110110
function! s:Initialize(state) abort
111-
let &l:filetype = 'copilot' . (empty(a:state.filetype) ? '' : '.' . a:state.filetype)
111+
try
112+
let &l:filetype = 'copilot' . (empty(a:state.filetype) ? '' : '.' . a:state.filetype)
113+
catch
114+
let &l:filetype = 'copilot'
115+
endtry
112116
let &l:tabstop = a:state.tabstop
113117
nmap <buffer><script> <CR> <Cmd>exe copilot#panel#Accept()<CR>
114118
nmap <buffer><script> [[ <Cmd>call search('^─\{9,}\n.', 'bWe')<CR>

autoload/copilot/version.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function! copilot#version#String() abort
2-
return '1.41.0'
2+
return '1.42.0'
33
endfunction
1.96 MB
Binary file not shown.
2.13 MB
Binary file not shown.
1.96 MB
Binary file not shown.
2.13 MB
Binary file not shown.
1.82 MB
Binary file not shown.

dist/language-server.js

+490-469
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/language-server.js.map

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tree-sitter-c_sharp.wasm

5.64 MB
Binary file not shown.

dist/tree-sitter-go.wasm

29.6 KB
Binary file not shown.

dist/tree-sitter-java.wasm

405 KB
Binary file not shown.

0 commit comments

Comments
 (0)