Skip to content

Commit e219dd9

Browse files
committed
Copilot.vim 1.5.2
1 parent 5544600 commit e219dd9

File tree

3 files changed

+9
-45
lines changed

3 files changed

+9
-45
lines changed

autoload/copilot.vim

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,6 @@ endif
3333

3434
let s:config_hosts = s:config_root . '/hosts.json'
3535

36-
function! s:JsonBody(response) abort
37-
if get(a:response.headers, 'content-type', '') =~# '^application/json\>'
38-
let body = a:response.body
39-
return json_decode(type(body) == v:t_list ? join(body) : body)
40-
else
41-
throw 'Copilot: expected application/json but got ' . get(a:response.headers, 'content-type', 'no content type')
42-
endif
43-
endfunction
44-
45-
function! copilot#HttpRequest(url, options, ...) abort
46-
return call('copilot#Call', ['httpRequest', extend({'url': a:url, 'timeout': 30000}, a:options)] + a:000)
47-
endfunction
48-
4936
function! s:StatusNotification(params, ...) abort
5037
let status = get(a:params, 'status', '')
5138
if status ==? 'error'
@@ -526,30 +513,6 @@ endfunction
526513

527514
let s:commands = {}
528515

529-
function s:NetworkStatusMessage() abort
530-
let err = copilot#Agent().StartupError()
531-
if !empty(err)
532-
return err
533-
endif
534-
try
535-
let info = copilot#agent#EditorInfo()
536-
let response = copilot#HttpRequest('https://copilot-proxy.githubusercontent.com/_ping',
537-
\ {'timeout': 5000, 'headers': {
538-
\ 'Editor-Version': info.editorInfo.name . '/' . info.editorInfo.version,
539-
\ 'Editor-Plugin-Version': info.editorPluginInfo.name . '/' . info.editorPluginInfo.version,
540-
\ }})
541-
if response.status == 466
542-
return "Server error:\n" . substitute(response.body, "\n$", '', '')
543-
endif
544-
catch /\%( timed out after \| getaddrinfo \|ERR_HTTP2_INVALID_SESSION\)/
545-
call copilot#logger#Exception()
546-
return 'Server connectivity issue'
547-
catch
548-
call copilot#logger#Exception()
549-
endtry
550-
return ''
551-
endfunction
552-
553516
function! s:EnabledStatusMessage() abort
554517
let buf_disabled = s:BufferDisabled()
555518
if !s:has_ghost_text && bufwinid('copilot://') == -1
@@ -605,9 +568,9 @@ function! s:commands.status(opts) abort
605568
return
606569
endif
607570

608-
let network_status = s:NetworkStatusMessage()
609-
if !empty(network_status)
610-
echo 'Copilot: ' . network_status
571+
let startup_error = copilot#Agent().StartupError()
572+
if !empty(startup_error)
573+
echo 'Copilot: ' . startup_error
611574
return
612575
endif
613576

@@ -630,9 +593,10 @@ function! s:commands.signout(opts) abort
630593
endfunction
631594

632595
function! s:commands.setup(opts) abort
633-
let network_status = s:NetworkStatusMessage()
634-
if !empty(network_status)
635-
return 'echoerr ' . string('Copilot: ' . network_status)
596+
let startup_error = copilot#Agent().StartupError()
597+
if !empty(startup_error)
598+
echo 'Copilot: ' . startup_error
599+
return
636600
endif
637601

638602
let browser = copilot#Browser()

autoload/copilot/agent.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let g:autoloaded_copilot_agent = 1
55

66
scriptencoding utf-8
77

8-
let s:plugin_version = '1.5.1'
8+
let s:plugin_version = '1.5.2'
99

1010
let s:error_exit = -1
1111

0 commit comments

Comments
 (0)