Skip to content

Commit 9e869d2

Browse files
committed
Copilot.vim 1.8.3
1 parent c7d166e commit 9e869d2

File tree

4 files changed

+48
-13
lines changed

4 files changed

+48
-13
lines changed

autoload/copilot.vim

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ if s:has_vim_ghost_text && empty(prop_type_get(s:annot_hlgroup))
1919
call prop_type_add(s:annot_hlgroup, {'highlight': s:annot_hlgroup})
2020
endif
2121

22+
function! s:Echo(msg) abort
23+
if has('nvim') && &cmdheight == 0
24+
call v:lua.vim.notify(a:msg, v:null, {'title': 'GitHub Copilot'})
25+
else
26+
echo a:msg
27+
endif
28+
endfunction
29+
2230
function! s:EditorConfiguration() abort
2331
let filetypes = copy(s:filetype_defaults)
2432
if type(get(g:, 'copilot_filetypes')) == v:t_dict
2533
call extend(filetypes, g:copilot_filetypes)
2634
endif
2735
return {
2836
\ 'enableAutoCompletions': empty(get(g:, 'copilot_enabled', 1)) ? v:false : v:true,
29-
\ 'disabledLanguages': map(sort(keys(filter(filetypes, { k, v -> empty(v) ? v:true : v:false }))), { _, v -> {'languageId': v}}),
37+
\ 'disabledLanguages': map(sort(keys(filter(filetypes, { k, v -> empty(v) }))), { _, v -> {'languageId': v}}),
3038
\ }
3139
endfunction
3240

@@ -199,6 +207,11 @@ function! s:SuggestionTextWithAdjustments() abort
199207
endif
200208
let typed = strpart(line, 0, offset)
201209
let delete = strpart(line, offset)
210+
if choice.range.end.line == line('.') - 1 && choice.range.end.character < copilot#doc#UTF16Width(line)
211+
let append = delete
212+
else
213+
let append = ''
214+
endif
202215
let uuid = get(choice, 'uuid', '')
203216
if typed =~# '^\s*$'
204217
let leading = matchstr(choice.text, '^\s\+')
@@ -207,7 +220,7 @@ function! s:SuggestionTextWithAdjustments() abort
207220
return [unindented, len(typed) - len(leading), strchars(delete), uuid]
208221
endif
209222
elseif typed ==# strpart(choice.text, 0, offset)
210-
return [strpart(choice.text . delete, offset), 0, strchars(delete), uuid]
223+
return [strpart(choice.text . append, offset), 0, strchars(delete), uuid]
211224
endif
212225
catch
213226
call copilot#logger#Exception()
@@ -439,6 +452,9 @@ endfunction
439452
function! copilot#OnInsertEnter() abort
440453
let s:is_mapped = copilot#IsMapped()
441454
let s:dest = bufnr('^copilot://$')
455+
if s:dest > 0 && bufwinnr(s:dest) < 0
456+
let s:dest = -1
457+
endif
442458
if s:dest < 0 && !s:has_ghost_text
443459
let s:dest = 0
444460
endif
@@ -622,16 +638,16 @@ function! s:commands.setup(opts) abort
622638
let @+ = data.userCode
623639
let @* = data.userCode
624640
endif
625-
echo "First copy your one-time code: " . data.userCode
641+
call s:Echo("First copy your one-time code: " . data.userCode)
626642
try
627643
if len(&mouse)
628644
let mouse = &mouse
629645
set mouse=
630646
endif
631647
if get(a:opts, 'bang')
632-
echo "In your browser, visit " . uri
648+
call s:Echo("In your browser, visit " . uri)
633649
elseif len(browser)
634-
echo "Press ENTER to open GitHub in your browser"
650+
call s:Echo("Press ENTER to open GitHub in your browser")
635651
let c = getchar()
636652
while c isnot# 13 && c isnot# 10 && c isnot# 0
637653
let c = getchar()
@@ -643,14 +659,14 @@ function! s:commands.setup(opts) abort
643659
sleep 10m
644660
endwhile
645661
if get(status, 'code', browser[0] !=# 'xdg-open') != 0
646-
echo "Failed to open browser. Visit " . uri
662+
call s:Echo("Failed to open browser. Visit " . uri)
647663
else
648-
echo "Opened " . uri
664+
call s:Echo("Opened " . uri)
649665
endif
650666
else
651-
echo "Could not find browser. Visit " . uri
667+
call s:Echo("Could not find browser. Visit " . uri)
652668
endif
653-
echo "Waiting (could take up to 5 seconds)"
669+
call s:Echo("Waiting (could take up to 5 seconds)")
654670
let request = copilot#Request('signInConfirm', {'userCode': data.userCode}).Wait()
655671
finally
656672
if exists('mouse')

autoload/copilot/agent.vim

Lines changed: 1 addition & 1 deletion
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.8.2'
8+
let s:plugin_version = '1.8.3'
99

1010
let s:error_exit = -1
1111

copilot/dist/agent.js

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

syntax/copilot.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
scriptencoding utf-8
2+
3+
if exists("b:current_syntax")
4+
finish
5+
endif
6+
7+
let s:subtype = matchstr(&l:filetype, '\<copilot\.\zs[[:alnum:]_-]\+')
8+
if !empty(s:subtype) && s:subtype !=# 'copilot'
9+
exe 'syn include @copilotLanguageTop syntax/' . s:subtype . '.vim'
10+
unlet! b:current_syntax
11+
endif
12+
13+
syn region copilotHeader start="\%^" end="^─\@="
14+
syn region copilotSolution matchgroup=copilotSeparator start="^─\{9,}$" end="\%(^─\{9,\}$\)\@=\|\%$" keepend contains=@copilotLanguageTop
15+
16+
hi def link copilotHeader PreProc
17+
hi def link copilotSeparator Comment
18+
19+
let b:current_syntax = "copilot"

0 commit comments

Comments
 (0)