Skip to content

Commit 69455be

Browse files
committed
Copilot.vim 1.22.0
1 parent 8f24a74 commit 69455be

File tree

5 files changed

+267
-317
lines changed

5 files changed

+267
-317
lines changed

autoload/copilot.vim

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function! s:StatusNotification(params, ...) abort
4444
endfunction
4545

4646
function! copilot#Init(...) abort
47-
call timer_start(0, { _ -> s:Start() })
47+
call timer_start(0, { _ -> exists('s:agent') || s:Start() })
4848
endfunction
4949

5050
function! s:Running() abort
@@ -401,6 +401,9 @@ function! s:HandleTriggerResult(result) abort
401401
endfunction
402402

403403
function! copilot#Suggest() abort
404+
if !s:Running()
405+
return ''
406+
endif
404407
try
405408
call copilot#Complete(function('s:HandleTriggerResult'), function('s:HandleTriggerResult'))
406409
catch
@@ -418,13 +421,8 @@ function! s:Trigger(bufnr, timer) abort
418421
return copilot#Suggest()
419422
endfunction
420423

421-
function! copilot#IsMapped() abort
422-
return get(g:, 'copilot_assume_mapped') ||
423-
\ hasmapto('copilot#Accept(', 'i')
424-
endfunction
425-
426424
function! copilot#Schedule(...) abort
427-
if !s:has_ghost_text || !copilot#Enabled() || !copilot#IsMapped()
425+
if !s:has_ghost_text || !copilot#Enabled()
428426
call copilot#Clear()
429427
return
430428
endif
@@ -434,6 +432,20 @@ function! copilot#Schedule(...) abort
434432
let g:_copilot_timer = timer_start(delay, function('s:Trigger', [bufnr('')]))
435433
endfunction
436434

435+
function! s:SyncTextDocument(bufnr, ...) abort
436+
try
437+
return copilot#Agent().SyncTextDocument(a:bufnr)
438+
catch
439+
call copilot#logger#Exception()
440+
endtry
441+
endfunction
442+
443+
function! copilot#OnFileType() abort
444+
if empty(s:BufferDisabled())
445+
call timer_start(0, function('s:SyncTextDocument', [bufnr('')]))
446+
endif
447+
endfunction
448+
437449
function! copilot#OnInsertLeave() abort
438450
return copilot#Clear()
439451
endfunction
@@ -547,8 +559,6 @@ function! s:EnabledStatusMessage() abort
547559
else
548560
return "Vim " . s:vim_minimum_version . " required to support ghost text"
549561
endif
550-
elseif !copilot#IsMapped()
551-
return '<Tab> map has been disabled or is claimed by another plugin'
552562
elseif !get(g:, 'copilot_enabled', 1)
553563
return 'Disabled globally by :Copilot disable'
554564
elseif buf_disabled is# 5

autoload/copilot/version.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function! copilot#version#String() abort
2-
return '1.21.0'
2+
return '1.22.0'
33
endfunction

dist/agent.js

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

dist/agent.js.map

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

plugin/copilot.vim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ endfunction
5252

5353
augroup github_copilot
5454
autocmd!
55+
autocmd FileType * call s:Event('FileType')
5556
autocmd InsertLeave * call s:Event('InsertLeave')
5657
autocmd BufLeave * if mode() =~# '^[iR]'|call s:Event('InsertLeave')|endif
5758
autocmd InsertEnter * call s:Event('InsertEnter')
5859
autocmd BufEnter * if mode() =~# '^[iR]'|call s:Event('InsertEnter')|endif
5960
autocmd CursorMovedI * call s:Event('CursorMovedI')
6061
autocmd CompleteChanged * call s:Event('CompleteChanged')
6162
autocmd ColorScheme,VimEnter * call s:ColorScheme()
62-
autocmd VimEnter * call s:MapTab()
63+
autocmd VimEnter * call s:MapTab() | call copilot#Init()
6364
autocmd BufUnload * call s:Event('BufUnload')
6465
autocmd VimLeavePre * call s:Event('VimLeavePre')
6566
autocmd BufReadCmd copilot://* setlocal buftype=nofile bufhidden=wipe nobuflisted nomodifiable
@@ -106,8 +107,6 @@ if !get(g:, 'copilot_no_maps')
106107
endtry
107108
endif
108109

109-
call copilot#Init()
110-
111110
let s:dir = expand('<sfile>:h:h')
112111
if getftime(s:dir . '/doc/copilot.txt') > getftime(s:dir . '/doc/tags')
113112
silent! execute 'helptags' fnameescape(s:dir . '/doc')

0 commit comments

Comments
 (0)