@@ -26,15 +26,6 @@ function! s:Warn(msg) abort
2626 echohl NONE
2727endfunction
2828
29- let s: node_target = ' 18.x or newer'
30- function ! s: UpgradeNodeMsg (node) abort
31- if get (a: node , 0 , ' node' ) == # ' node'
32- return ' Upgrade to ' . s: node_target
33- else
34- return ' Change g:copilot_node_command to ' . s: node_target
35- endif
36- endfunction
37-
3829function ! s: VimClose () dict abort
3930 if ! has_key (self , ' job' )
4031 return
@@ -387,8 +378,10 @@ function! s:OnExit(instance, code, ...) abort
387378 call remove (a: instance , ' client_id' )
388379 endif
389380 let message = ' Process exited with status ' . a: code
390- if a: code == 2
391- let message = ' Node.js too old. ' . s: UpgradeNodeMsg (a: instance .node)
381+ if a: code >= 18 && a: code < 100
382+ let message = ' Node.js too old. ' .
383+ \ (get (a: instance .node, 0 , ' node' ) == # ' node' ? ' Upgrade' : ' Change g:copilot_node_command' ) .
384+ \ ' to ' . a: code . ' .x or newer'
392385 endif
393386 if ! has_key (a: instance , ' serverInfo' ) && ! has_key (a: instance , ' startup_error' )
394387 let a: instance .startup_error = message
@@ -496,7 +489,7 @@ endfunction
496489
497490let s: script_name = ' dist/language-server.js'
498491function ! s: Command () abort
499- if ! has (' nvim-0.6 ' ) && v: version < 900
492+ if ! has (' nvim-0.7 ' ) && v: version < 900
500493 return [[], [], ' Vim version too old' ]
501494 endif
502495 let script = get (g: , ' copilot_command' , ' ' )
@@ -566,10 +559,6 @@ function! s:PostInit(result, instance) abort
566559 let a: instance .serverInfo = get (a: result , ' serverInfo' , {})
567560 if ! has_key (a: instance , ' node_version' ) && has_key (a: result .serverInfo, ' nodeVersion' )
568561 let a: instance .node_version = a: result .serverInfo.nodeVersion
569- if a: instance .node_version = ~# ' ^1[67]\.'
570- let a: instance .node_version_warning = ' Node.js ' . a: instance .node_version . ' support will soon be dropped. ' . s: UpgradeNodeMsg (a: instance .node)
571- call s: Warn (a: instance .node_version_warning)
572- endif
573562 endif
574563 let a: instance .AfterInitialized = function (' copilot#util#Defer' )
575564 for Fn in remove (a: instance , ' after_initialized' )
@@ -686,21 +675,21 @@ function! copilot#client#New(...) abort
686675 endfor
687676 if has (' nvim' )
688677 call extend (instance, {
689- \ ' Close' : function (' s:NvimClose' ),
690- \ ' Notify' : function (' s:NvimNotify' ),
691- \ ' Request' : function (' s:NvimRequest' ),
692- \ ' Attach' : function (' s:NvimAttach' ),
693- \ ' IsAttached' : function (' s:NvimIsAttached' ),
694- \ })
678+ \ ' Close' : function (' s:NvimClose' ),
679+ \ ' Notify' : function (' s:NvimNotify' ),
680+ \ ' Request' : function (' s:NvimRequest' ),
681+ \ ' Attach' : function (' s:NvimAttach' ),
682+ \ ' IsAttached' : function (' s:NvimIsAttached' ),
683+ \ })
695684 let instance.client_id = eval (" v:lua.require'_copilot'.lsp_start_client(command, keys(instance.methods), opts, settings)" )
696685 let instance.id = instance.client_id
697686 else
698687 call extend (instance, {
699- \ ' Close' : function (' s:VimClose' ),
700- \ ' Notify' : function (' s:VimNotify' ),
701- \ ' Attach' : function (' s:VimAttach' ),
702- \ ' IsAttached' : function (' s:VimIsAttached' ),
703- \ })
688+ \ ' Close' : function (' s:VimClose' ),
689+ \ ' Notify' : function (' s:VimNotify' ),
690+ \ ' Attach' : function (' s:VimAttach' ),
691+ \ ' IsAttached' : function (' s:VimIsAttached' ),
692+ \ })
704693 let state = {' headers' : {}, ' mode' : ' headers' , ' buffer' : ' ' }
705694 let instance.open_buffers = {}
706695 let instance.methods = extend (s: vim_handlers , instance.methods)
0 commit comments