@@ -5,13 +5,15 @@ let g:autoloaded_copilot_agent = 1
55
66scriptencoding utf- 8
77
8- let s: plugin_version = ' 1.3.0 '
8+ let s: plugin_version = ' 1.3.1 '
99
1010let s: error_exit = -1
1111
1212let s: root = expand (' <sfile>:h:h:h' )
1313
14- let s: instances = {}
14+ if ! exists (' s:instances' )
15+ let s: instances = {}
16+ endif
1517
1618let s: jobstop = function (exists (' *jobstop' ) ? ' jobstop' : ' job_stop' )
1719function ! s: Kill (agent, ... ) abort
@@ -119,6 +121,7 @@ endfunction
119121function ! s: AgentCancel (request) dict abort
120122 if has_key (self .requests, get (a: request , ' id' , ' ' ))
121123 call remove (self .requests, a: request .id)
124+ call self .Notify (' $/cancelRequest' , {' id' : a: request .id})
122125 endif
123126 if get (a: request , ' status' , ' ' ) == # ' running'
124127 let a: request .status = ' canceled'
@@ -132,6 +135,7 @@ function! s:RequestCancel() dict abort
132135 elseif get (self , ' status' , ' ' ) == # ' running'
133136 let self .status = ' canceled'
134137 endif
138+ return self
135139endfunction
136140
137141function ! s: DispatchMessage (agent, handler, id, params, ... ) abort
@@ -272,32 +276,38 @@ function! s:IsArmMacOS() abort
272276endfunction
273277
274278function ! s: Command () abort
275- if ! has (' nvim-0.5 ' ) && v: version < 802
279+ if ! has (' nvim-0.6 ' ) && v: version < 802
276280 return [v: null , ' Vim version too old' ]
277281 endif
278- let node = get (g: , ' copilot_node_command' , ' node' )
279- if type (node) == type (' ' )
280- let node = [node]
282+ let node = get (g: , ' copilot_node_command' , ' ' )
283+ if empty (node)
284+ let node = [' node' ]
285+ elseif type (node) == type (' ' )
286+ let node = [expand (node)]
281287 endif
282288 if ! executable (get (node, 0 , ' ' ))
283289 if get (node, 0 , ' ' ) == # ' node'
284- return [v: null , ' Node not found in PATH' ]
290+ return [v: null , ' Node.js not found in PATH' ]
285291 else
286- return [v: null , ' Node executable `' . get (node, 0 , ' ' ) . " ' not found" ]
292+ return [v: null , ' Node.js executable `' . get (node, 0 , ' ' ) . " ' not found" ]
287293 endif
288294 endif
289295 let out = []
290296 let err = []
291297 let status = copilot#job#Stream (node + [' --version' ], function (' add' , [out]), function (' add' , [err]))
292298 if status != 0
293- return [v: null , ' Node exited with status ' . status]
299+ return [v: null , ' Node.js exited with status ' . status]
294300 endif
295- let major = + matchstr (join (out, ' ' ), ' ^v\zs\d\+\ze\.' )
301+ let node_version = matchstr (join (out, ' ' ), ' ^v\zs\d\+\.[^[:space:]]*' )
302+ let major = str2nr (node_version)
303+ let too_new = major >= 18 && node_version !=# ' 18.0.0'
296304 if ! get (g: , ' copilot_ignore_node_version' )
297- if major < 16 && s: IsArmMacOS ()
298- return [v: null , ' Node v16+ required on Apple Silicon but found ' . get (out, 0 , ' nothing' )]
299- elseif major < 12
300- return [v: null , ' Node v12+ required but found ' . get (out, 0 , ' nothing' )]
305+ if major == 0
306+ return [v: null , ' Could not determine Node.js version' ]
307+ elseif (major < 16 || too_new) && s: IsArmMacOS ()
308+ return [v: null , ' Node.js version 16.x or 17.x required on Apple Silicon but found ' . node_version]
309+ elseif major < 12 || too_new
310+ return [v: null , ' Node.js version 12.x–17.x required but found ' . node_version]
301311 endif
302312 endif
303313 let agent = s: root . ' /copilot/dist/agent.js'
0 commit comments