@@ -43,7 +43,7 @@ function! s:Running() abort
43
43
endfunction
44
44
45
45
function ! s: Start ()abort
46
- if s: Running ()
46
+ if s: Running ()|| exists ( ' s:client.startup_error ' )
47
47
return
48
48
endif
49
49
let s: client= copilot#client#New ({' editorConfiguration' :s: EditorConfiguration ()})
@@ -70,11 +70,7 @@ function! copilot#RunningClient() abort
70
70
endfunction
71
71
72
72
function ! s: NodeVersionWarning ()abort
73
- if exists (' s:client.node_version' )&& s: client .node_version= ~#' ^1[67]\.'
74
- echohl WarningMsg
75
- echo " Warning: Node.js" matchstr (s: client .node_version,' ^\d\+' )" is end-of-life and support will be dropped in a future release of copilot.vim."
76
- echohl NONE
77
- elseif exists (' s:client.node_version_warning' )
73
+ if exists (' s:client.node_version_warning' )
78
74
echohl WarningMsg
79
75
echo ' Warning:' s: client .node_version_warning
80
76
echohl NONE
@@ -202,9 +198,9 @@ function! copilot#Complete(...) abort
202
198
if ! a: 0
203
199
return completion.Await ()
204
200
else
205
- call copilot#client#Result (completion,a: 1 )
201
+ call copilot#client#Result (completion,function ( a: 1, [ b: _copilot ]) )
206
202
if a: 0 > 1
207
- call copilot#client#Error (completion,a: 2 )
203
+ call copilot#client#Error (completion,function ( a: 2, [ b: _copilot ]) )
208
204
endif
209
205
endif
210
206
endfunction
@@ -371,21 +367,29 @@ function! s:UpdatePreview() abort
371
367
endtry
372
368
endfunction
373
369
374
- function ! s: HandleTriggerResult (result)abort
375
- if ! exists (' b:_copilot' )
376
- return
370
+ function ! s: HandleTriggerResult (state , result)abort
371
+ let a: state .suggestions= type (a: result )== type ([]) ?a: result :get (empty (a: result ) ? {} :a: result ,' items' , [])
372
+ let a: state .choice= 0
373
+ if get (b: ,' _copilot' )is #a: state
374
+ call s: UpdatePreview ()
375
+ endif
376
+ endfunction
377
+
378
+ function ! s: HandleTriggerError (state , result)abort
379
+ let a: state .suggestions= []
380
+ let a: state .choice= 0
381
+ let a: state .error = a: result
382
+ if get (b: ,' _copilot' )is #a: state
383
+ call s: UpdatePreview ()
377
384
endif
378
- let b: _copilot .suggestions= type (a: result )== type ([]) ?a: result :get (empty (a: result ) ? {} :a: result ,' items' , [])
379
- let b: _copilot .choice= 0
380
- call s: UpdatePreview ()
381
385
endfunction
382
386
383
387
function ! copilot#Suggest ()abort
384
388
if ! s: Running ()
385
389
return ' '
386
390
endif
387
391
try
388
- call copilot#Complete (function (' s:HandleTriggerResult' ),function (' s:HandleTriggerResult ' ))
392
+ call copilot#Complete (function (' s:HandleTriggerResult' ),function (' s:HandleTriggerError ' ))
389
393
catch
390
394
call copilot#logger#Exception ()
391
395
endtry