Skip to content

Commit 8f24a74

Browse files
committed
Copilot.vim 1.21.0
1 parent 4d32b06 commit 8f24a74

File tree

12 files changed

+467
-320
lines changed

12 files changed

+467
-320
lines changed

autoload/copilot.vim

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ function! copilot#RunningAgent() abort
8484
endfunction
8585

8686
function! s:NodeVersionWarning() abort
87-
if exists('s:agent.node_version') && s:agent.node_version =~# '^16\.'
87+
if exists('s:agent.node_version') && s:agent.node_version =~# '^1[67]\.'
8888
echohl WarningMsg
89-
echo "Warning: Node.js 16 is approaching end of life and support will be dropped in a future release of copilot.vim."
89+
echo "Warning: Node.js" matchstr(s:agent.node_version, '^\d\+') "is end-of-life and support will be dropped in a future release of copilot.vim."
9090
echohl NONE
9191
elseif exists('s:agent.node_version_warning')
9292
echohl WarningMsg
@@ -95,6 +95,20 @@ function! s:NodeVersionWarning() abort
9595
endif
9696
endfunction
9797

98+
if has('nvim-0.6') && !has(luaeval('vim.version().api_prerelease') ? 'nvim-0.7.1' : 'nvim-0.7.0')
99+
let s:editor_warning = 'Neovim 0.6 support is deprecated and will be dropped in a future release of copilot.vim.'
100+
endif
101+
if has('vim_starting') && exists('s:editor_warning')
102+
call copilot#logger#Warn(s:editor_warning)
103+
endif
104+
function! s:EditorVersionWarning() abort
105+
if exists('s:editor_warning')
106+
echohl WarningMsg
107+
echo 'Warning: ' . s:editor_warning
108+
echohl None
109+
endif
110+
endfunction
111+
98112
function! copilot#Request(method, params, ...) abort
99113
let agent = copilot#Agent()
100114
return call(agent.Request, [a:method, a:params] + a:000)
@@ -192,6 +206,12 @@ function! copilot#Complete(...) abort
192206
endif
193207
let params = copilot#doc#Params()
194208
if !exists('b:_copilot.params') || b:_copilot.params !=# params
209+
if exists('b:_copilot.first')
210+
call copilot#agent#Cancel(b:_copilot.first)
211+
endif
212+
if exists('b:_copilot.cycling')
213+
call copilot#agent#Cancel(b:_copilot.cycling)
214+
endif
195215
let b:_copilot = {'params': params, 'first':
196216
\ copilot#Request('getCompletions', params)}
197217
let g:_copilot_last = b:_copilot
@@ -598,6 +618,7 @@ function! s:commands.status(opts) abort
598618
endif
599619

600620
echo 'Copilot: Enabled and online'
621+
call s:EditorVersionWarning()
601622
call s:NodeVersionWarning()
602623
endfunction
603624

@@ -642,7 +663,7 @@ function! s:commands.setup(opts) abort
642663
if get(a:opts, 'bang')
643664
call s:Echo(codemsg . "In your browser, visit " . uri)
644665
elseif len(browser)
645-
call input(codemsg . "Press ENTER to open GitHub in your browser")
666+
call input(codemsg . "Press ENTER to open GitHub in your browser\n")
646667
let status = {}
647668
call copilot#job#Stream(browser + [uri], v:null, v:null, function('s:BrowserCallback', [status]))
648669
let time = reltime()
@@ -679,6 +700,7 @@ function! s:commands.setup(opts) abort
679700
endfunction
680701

681702
let s:commands.auth = s:commands.setup
703+
let s:commands.signin = s:commands.setup
682704

683705
function! s:commands.help(opts) abort
684706
return a:opts.mods . ' help ' . (len(a:opts.arg) ? ':Copilot_' . a:opts.arg : 'copilot')
@@ -700,10 +722,25 @@ function! s:commands.version(opts) abort
700722
else
701723
echo 'Node.js ' . substitute(get(versions.Await(), 'runtimeVersion', '?'), '^node/', '', 'g')
702724
endif
703-
call s:NodeVersionWarning()
704725
else
705726
echo 'Not running'
727+
if exists('s:agent.node_version')
728+
echo 'Node.js ' . s:agent.node_version
729+
endif
706730
endif
731+
if has('win32')
732+
echo 'Windows'
733+
elseif has('macunix')
734+
echo 'macOS'
735+
elseif !has('unix')
736+
echo 'Unknown OS'
737+
elseif isdirectory('/sys/kernel')
738+
echo 'Linux'
739+
else
740+
echo 'UNIX'
741+
endif
742+
call s:EditorVersionWarning()
743+
call s:NodeVersionWarning()
707744
endfunction
708745

709746
function! s:UpdateEditorConfiguration() abort
@@ -764,7 +801,7 @@ function! copilot#Command(line1, line2, range, bang, mods, arg) abort
764801
let cmd = matchstr(a:arg, '^\%(\\.\|\S\)\+')
765802
let arg = matchstr(a:arg, '\s\zs\S.*')
766803
if cmd ==# 'log'
767-
return a:mods . ' split +$ ' . fnameescape(copilot#logger#File())
804+
return a:mods . ' split +$ copilot:///log'
768805
endif
769806
if !empty(cmd) && !has_key(s:commands, tr(cmd, '-', '_'))
770807
return 'echoerr ' . string('Copilot: unknown command ' . string(cmd))
@@ -782,7 +819,7 @@ function! copilot#Command(line1, line2, range, bang, mods, arg) abort
782819
endtry
783820
if empty(cmd)
784821
if opts.status ==# 'VimException'
785-
return a:mods . ' split +$ ' . fnameescape(copilot#logger#File())
822+
return a:mods . ' split +$ copilot:///log'
786823
elseif opts.status !=# 'OK' && opts.status !=# 'MaybeOK'
787824
let cmd = 'setup'
788825
else

0 commit comments

Comments
 (0)