Skip to content

Commit e1be74e

Browse files
committed
Copilot.vim 1.0.1
1 parent 03a11ad commit e1be74e

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ Copilot.vim is a Vim plugin for GitHub Copilot. For now, it requires a Neovim
1010

1111
To learn more about GitHub Copilot, visit https://copilot.github.com.
1212

13+
## Technical Preview
14+
15+
Access to GitHub Copilot is limited to a small group of testers during the
16+
technical preview of GitHub Copilot. If you don’t have access to the technical
17+
preview, you will see an error when you try to use this extension.
18+
19+
Don’t have access yet? [Sign up for the
20+
waitlist](https://github.com/features/copilot/signup) for your chance to try
21+
it out. GitHub will notify you once you have access.
22+
23+
This technical preview is a Beta Preview under the [GitHub Terms of
24+
Service](https://docs.github.com/en/github/site-policy/github-terms-of-service#j-beta-previews).
25+
1326
## Getting started
1427

1528
1. Install [Node.js][] v12 or newer.

autoload/copilot.vim

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,17 @@ let s:filetype_defaults = {
216216
\ 'cvs': 0,
217217
\ '.': 0}
218218

219-
function! s:FileTypeDisabled(filetype) abort
220-
let short = empty(a:filetype) ? '.' : split(a:filetype, '\.', 1)[0]
219+
function! s:BufferDisabled() abort
220+
if exists('b:copilot_disabled')
221+
return b:copilot_disabled ? 3 : 0
222+
endif
223+
if exists('b:copilot_enabled')
224+
return b:copilot_enabled ? 4 : 0
225+
endif
226+
let short = empty(&l:filetype) ? '.' : split(&l:filetype, '\.', 1)[0]
221227
let config = get(g:, 'copilot_filetypes', {})
222-
if has_key(config, a:filetype)
223-
return empty(config[a:filetype])
228+
if has_key(config, &l:filetype)
229+
return empty(config[&l:filetype])
224230
elseif has_key(config, short)
225231
return empty(config[short])
226232
elseif has_key(config, '*')
@@ -233,8 +239,7 @@ endfunction
233239
function! copilot#Enabled() abort
234240
return !get(g:, 'copilot_disabled', 0)
235241
\ && s:TermsAccepted(0)
236-
\ && !get(b:, 'copilot_disabled', 0)
237-
\ && empty(s:FileTypeDisabled(&filetype))
242+
\ && empty(s:BufferDisabled())
238243
\ && empty(copilot#agent#StartupError())
239244
endfunction
240245

@@ -565,18 +570,20 @@ function s:NetworkStatusMessage() abort
565570
endfunction
566571

567572
function! s:EnabledStatusMessage() abort
568-
let ft_disabled = s:FileTypeDisabled(&filetype)
573+
let buf_disabled = s:BufferDisabled()
569574
if !s:has_ghost_text && bufwinid('copilot://') == -1
570575
return "Neovim 0.6 prerelease required to support ghost text"
571576
elseif !copilot#IsMapped()
572577
return '<Tab> map has been disabled or is claimed by another plugin'
573578
elseif get(g:, 'copilot_disabled', 0)
574579
return 'Disabled globally by :Copilot disable'
575-
elseif get(b:, 'copilot_disabled', 0)
580+
elseif buf_disabled is# 4
581+
return 'Disabled for current buffer by b:copilot_enabled'
582+
elseif buf_disabled is# 3
576583
return 'Disabled for current buffer by b:copilot_disabled'
577-
elseif ft_disabled is# 2
584+
elseif buf_disabled is# 2
578585
return 'Disabled for filetype=' . &filetype . ' by internal default'
579-
elseif ft_disabled
586+
elseif buf_disabled
580587
return 'Disabled for filetype=' . &filetype . ' by g:copilot_filetypes'
581588
elseif !copilot#Enabled()
582589
return 'BUG: Something is wrong with enabling/disabling'
@@ -633,7 +640,7 @@ function! s:commands.setup(opts) abort
633640
let @* = data.user_code
634641
echo "First copy your one-time code: " . data.user_code
635642
if len(browser)
636-
echo "Press ENTER to open github.com in your browser"
643+
echo "Press ENTER to open " . data.verification_uri . " in your browser"
637644
try
638645
if len(&mouse)
639646
let mouse = &mouse
@@ -651,8 +658,6 @@ function! s:commands.setup(opts) abort
651658
let exit_status = copilot#job#Stream(browser + [data.verification_uri], v:null, v:null)
652659
if exit_status
653660
echo "Failed to open browser. Visit " . data.verification_uri
654-
else
655-
redraw
656661
endif
657662
else
658663
echo "Could not find browser. Visit " . data.verification_uri

autoload/copilot/doc.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let g:autoloaded_copilot_prompt = 1
66
scriptencoding utf-8
77

88
function copilot#doc#UTF16Width(str) abort
9-
return strchars(substitute(a:str, "[^\u0001-\uffff]", " ", 'g'))
9+
return strchars(substitute(a:str, "\\%#=2[^\u0001-\uffff]", " ", 'g'))
1010
endfunction
1111

1212
let s:language_normalization_map = {

doc/copilot.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ g:copilot_filetypes A dictionary mapping file types to their enabled
4949
<
5050
*b:copilot_disabled*
5151
b:copilot_disabled Set to v:true to disable GitHub Copilot for the
52-
current buffer.
52+
current buffer. Or set to v:false force enabling it,
53+
regardless of g:copilot_filetypes.
5354

5455
vim:tw=78:et:ft=help:norl:

0 commit comments

Comments
 (0)