Skip to content

Commit 59c0239

Browse files
committed
Copilot.vim 1.11.0
1 parent 998cf5a commit 59c0239

File tree

9 files changed

+680
-87
lines changed

9 files changed

+680
-87
lines changed

autoload/copilot.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function! copilot#Schedule(...) abort
413413
if !s:has_ghost_text || !copilot#Enabled() || !copilot#IsMapped()
414414
return
415415
endif
416-
let delay = a:0 ? a:1 : get(g:, 'copilot_idle_delay', 75)
416+
let delay = a:0 ? a:1 : get(g:, 'copilot_idle_delay', 15)
417417
let g:_copilot_timer = timer_start(delay, function('s:Trigger', [bufnr('')]))
418418
endfunction
419419

autoload/copilot/agent.vim

Lines changed: 9 additions & 13 deletions
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.10.3'
8+
let s:plugin_version = '1.11.0'
99

1010
let s:error_exit = -1
1111

@@ -400,7 +400,8 @@ function! s:GetNodeVersion(command) abort
400400
let string = ''
401401
endif
402402
let major = str2nr(string)
403-
return {'status': status, 'string': string, 'major': major}
403+
let minor = str2nr(matchstr(string, '\.\zs\d\+'))
404+
return {'status': status, 'string': string, 'major': major, 'minor': minor}
404405
endfunction
405406

406407
function! s:Command() abort
@@ -422,7 +423,7 @@ function! s:Command() abort
422423
endif
423424
let node_version = s:GetNodeVersion(node)
424425
let warning = ''
425-
if node_version.major < 18 && get(node, 0, '') !=# 'node'
426+
if node_version.major < 18 && get(node, 0, '') !=# 'node' && executable('node')
426427
let node_version_from_path = s:GetNodeVersion(['node'])
427428
if node_version_from_path.major >= 18
428429
let warning = 'Ignoring g:copilot_node_command: Node.js ' . node_version.string . ' is end-of-life'
@@ -436,8 +437,9 @@ function! s:Command() abort
436437
if !get(g:, 'copilot_ignore_node_version')
437438
if node_version.major == 0
438439
return [v:null, node_version.string, 'Could not determine Node.js version']
439-
elseif node_version.major < 16
440-
return [v:null, node_version.string, 'Node.js version 16.x or newer required but found ' . node_version.string]
440+
elseif node_version.major < 16 || node_version.major == 16 && node_version.minor < 14
441+
" 16.14+ still works for now, but is end-of-life
442+
return [v:null, node_version.string, 'Node.js version 18.x or newer required but found ' . node_version.string]
441443
endif
442444
endif
443445
let agent = get(g:, 'copilot_agent_command', '')
@@ -447,7 +449,7 @@ function! s:Command() abort
447449
return [v:null, node_version.string, 'Could not find dist/agent.js (bad install?)']
448450
endif
449451
endif
450-
return [node + [agent], node_version.string, warning]
452+
return [node + [agent, '--stdio'], node_version.string, warning]
451453
endfunction
452454

453455
function! s:UrlDecode(str) abort
@@ -490,13 +492,7 @@ endfunction
490492

491493
function! s:GetCapabilitiesResult(result, agent) abort
492494
let a:agent.capabilities = get(a:result, 'capabilities', {})
493-
let info = deepcopy(copilot#agent#EditorInfo())
494-
let info.editorInfo.version .= ' + Node.js ' . a:agent.node_version
495-
if has_key(a:agent, 'node_version_warning')
496-
let info.editorInfo.version .= ' (ignored g:copilot_node_command)'
497-
elseif !empty(get(g:, 'copilot_node_command', ''))
498-
let info.editorInfo.version .= ' (used g:copilot_node_command)'
499-
endif
495+
let info = copilot#agent#EditorInfo()
500496
call a:agent.Request('setEditorInfo', extend({'editorConfiguration': a:agent.editorConfiguration}, info))
501497
endfunction
502498

autoload/copilot/job.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ function! copilot#job#Stream(argv, out_cb, err_cb, ...) abort
7676
let OutCb = function(empty(a:out_cb) ? 'copilot#job#Nop' : a:out_cb, a:000[2:-1])
7777
let ErrCb = function(empty(a:err_cb) ? 'copilot#job#Nop' : a:err_cb, a:000[2:-1])
7878
let state = {'headers': {}, 'mode': 'headers', 'buffer': ''}
79+
let cwd = expand("~")
80+
if !isdirectory(cwd) && isdirectory($VIM)
81+
let cwd = $VIM
82+
endif
7983
if exists('*job_start')
8084
let result = {}
8185
let job = job_start(a:argv, {
82-
\ 'cwd': expand("~"),
86+
\ 'cwd': cwd,
8387
\ 'out_mode': 'raw',
8488
\ 'out_cb': { j, d -> OutCb(d) },
8589
\ 'err_cb': { j, d -> ErrCb(d) },
@@ -88,7 +92,7 @@ function! copilot#job#Stream(argv, out_cb, err_cb, ...) abort
8892
\ })
8993
else
9094
let jopts = {
91-
\ 'cwd': expand("~"),
95+
\ 'cwd': cwd,
9296
\ 'stderr': [''],
9397
\ 'on_stdout': { j, d, t -> OutCb(join(d, "\n")) },
9498
\ 'on_stderr': function('s:NvimCallback', [ErrCb]),

dist/agent.js

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

dist/agent.js.LICENSE.txt

Lines changed: 0 additions & 44 deletions
This file was deleted.

dist/agent.js.map

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
10.3 KB
Binary file not shown.

dist/crypt32.node

10.3 KB
Binary file not shown.

doc/copilot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ g:copilot_node_command Tell Copilot what `node` binary to use with
7272
in your PATH is an unsupported version.
7373
>
7474
let g:copilot_node_command =
75-
\ "~/.nodenv/versions/16.15.0/bin/node"
75+
\ "~/.nodenv/versions/18.18.0/bin/node"
7676
<
7777
*g:copilot_proxy*
7878
g:copilot_proxy Tell Copilot what proxy server to use. This is a

0 commit comments

Comments
 (0)