Skip to content

Commit 9484e35

Browse files
committed
Copilot.vim 1.26.0
1 parent 3b39e78 commit 9484e35

File tree

7 files changed

+299
-285
lines changed

7 files changed

+299
-285
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Auto-close PR
2+
on:
3+
pull_request_target:
4+
types: [opened, reopened]
5+
6+
jobs:
7+
close:
8+
name: Run
9+
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: write
12+
steps:
13+
- run: |
14+
gh pr close ${{ github.event.pull_request.number }} --comment \
15+
"At the moment we are not accepting contributions to the repository.
16+
17+
Feedback for Copilot.vim can be given in the [Copilot community discussions](https://github.com/orgs/community/discussions/categories/copilot)."
18+
env:
19+
GH_REPO: ${{ github.repository }}
20+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

autoload/copilot.vim

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ function! s:EditorConfiguration() abort
3434
\ }
3535
endfunction
3636

37-
function! s:StatusNotification(params, ...) abort
38-
let status = get(a:params, 'status', '')
39-
if status ==? 'error'
40-
let s:agent_error = a:params.message
41-
else
42-
unlet! s:agent_error
43-
endif
44-
endfunction
45-
4637
function! copilot#Init(...) abort
4738
call copilot#util#Defer({ -> exists('s:agent') || s:Start() })
4839
endfunction
@@ -56,7 +47,6 @@ function! s:Start() abort
5647
return
5748
endif
5849
let s:agent = copilot#agent#New({'methods': {
59-
\ 'statusNotification': function('s:StatusNotification'),
6050
\ 'PanelSolution': function('copilot#panel#Solution'),
6151
\ 'PanelSolutionsDone': function('copilot#panel#SolutionsDone'),
6252
\ },
@@ -611,6 +601,12 @@ function! s:VerifySetup() abort
611601
echo 'Copilot: Telemetry terms not accepted. Invoke :Copilot setup'
612602
return
613603
endif
604+
605+
if status.status ==# 'NotAuthorized'
606+
echo "Copilot: You don't have access to GitHub Copilot. Sign up by visiting https://github.com/settings/copilot"
607+
return
608+
endif
609+
614610
return 1
615611
endfunction
616612

@@ -619,30 +615,21 @@ function! s:commands.status(opts) abort
619615
return
620616
endif
621617

622-
let status = s:EnabledStatusMessage()
623-
if !empty(status)
624-
echo 'Copilot: ' . status
625-
return
626-
endif
627-
628-
let startup_error = copilot#Agent().StartupError()
629-
if !empty(startup_error)
630-
echo 'Copilot: ' . startup_error
631-
return
632-
endif
633-
634-
if exists('s:agent_error')
635-
echo 'Copilot: ' . s:agent_error
618+
if exists('s:agent.status.status') && s:agent.status.status =~# 'Warning\|Error'
619+
echo 'Copilot: ' . s:agent.status.status
620+
if !empty(get(s:agent.status, 'message', ''))
621+
echon ': ' . s:agent.status.message
622+
endif
636623
return
637624
endif
638625

639-
let status = copilot#Call('checkStatus', {})
640-
if status.status ==# 'NotAuthorized'
641-
echo 'Copilot: Not authorized'
626+
let status = s:EnabledStatusMessage()
627+
if !empty(status)
628+
echo 'Copilot: ' . status
642629
return
643630
endif
644631

645-
echo 'Copilot: Enabled and online'
632+
echo 'Copilot: Ready'
646633
call s:EditorVersionWarning()
647634
call s:NodeVersionWarning()
648635
endfunction

autoload/copilot/agent.vim

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function! s:RejectRequest(request, error) abort
5151
if empty(reject)
5252
call copilot#logger#Error(msg)
5353
else
54-
call copilot#logger#Warn(msg)
54+
call copilot#logger#Debug(msg)
5555
endif
5656
endfunction
5757

@@ -185,7 +185,7 @@ function! s:RegisterWorkspaceFolderForBuffer(agent, buf) abort
185185
return
186186
endif
187187
let a:agent.workspaceFolders[root] = v:true
188-
call a:agent.Notify('workspace/didChangeWorkspaceFolders', {'event': {'added': [{'uri': root, 'name': fnamemodify(root, ':t')}]}})
188+
call a:agent.Notify('workspace/didChangeWorkspaceFolders', {'event': {'added': [{'uri': root, 'name': fnamemodify(root, ':t')}], 'removed': []}})
189189
endfunction
190190

191191
function! s:PreprocessParams(agent, params) abort
@@ -275,15 +275,15 @@ endfunction
275275

276276
function! s:DispatchMessage(agent, method, handler, id, params, ...) abort
277277
try
278-
let response = {'result': call(a:handler, [a:params])}
278+
let response = {'result': call(a:handler, [a:params, a:agent])}
279279
if response.result is# 0
280280
let response.result = v:null
281281
endif
282282
catch
283283
call copilot#logger#Exception('lsp.request.' . a:method)
284284
let response = {'error': {'code': -32000, 'message': v:exception}}
285285
endtry
286-
if !empty(a:id)
286+
if a:id isnot# v:null
287287
call s:Send(a:agent, extend({'id': a:id}, response))
288288
endif
289289
return response
@@ -556,12 +556,18 @@ function! s:AgentStartupError() dict abort
556556
endif
557557
endfunction
558558

559+
function! s:StatusNotification(params, agent) abort
560+
call copilot#logger#Info('StatusNotification ' . string(a:params))
561+
let a:agent.status = a:params
562+
endfunction
563+
559564
function! s:Nop(...) abort
560565
return v:null
561566
endfunction
562567

563568
let s:common_handlers = {
564569
\ 'featureFlagsNotification': function('s:Nop'),
570+
\ 'statusNotification': function('s:StatusNotification'),
565571
\ 'window/logMessage': function('copilot#handlers#window_logMessage'),
566572
\ }
567573

@@ -579,6 +585,7 @@ function! copilot#agent#New(...) abort
579585
let opts = a:0 ? a:1 : {}
580586
let instance = {'requests': {},
581587
\ 'workspaceFolders': {},
588+
\ 'status': {'status': 'Starting', 'message': ''},
582589
\ 'Close': function('s:AgentClose'),
583590
\ 'Notify': function('s:AgentNotify'),
584591
\ 'Request': function('s:AgentRequest'),

autoload/copilot/handlers.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function! copilot#handlers#window_logMessage(params) abort
1+
function! copilot#handlers#window_logMessage(params, ...) abort
22
call copilot#logger#Raw(get(a:params, 'type', 6), get(a:params, 'message', ''))
33
endfunction
44

5-
function! copilot#handlers#window_showMessageRequest(params) abort
5+
function! copilot#handlers#window_showMessageRequest(params, ...) abort
66
let choice = inputlist([a:params.message . "\n\nRequest Actions:"] +
77
\ map(copy(get(a:params, 'actions', [])), { i, v -> (i + 1) . '. ' . v.title}))
88
return choice > 0 ? get(a:params.actions, choice - 1, v:null) : v:null
@@ -12,7 +12,7 @@ function! s:BrowserCallback(into, code) abort
1212
let a:into.code = a:code
1313
endfunction
1414

15-
function! copilot#handlers#window_showDocument(params) abort
15+
function! copilot#handlers#window_showDocument(params, ...) abort
1616
echo a:params.uri
1717
if empty(get(a:params, 'external'))
1818
return {'success': v:false}

autoload/copilot/version.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function! copilot#version#String() abort
2-
return '1.25.1'
2+
return '1.26.0'
33
endfunction

dist/agent.js

Lines changed: 246 additions & 246 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/agent.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)