Skip to content

Commit bc33958

Browse files
author
Ok6683
authored
Update and rename copilot.vim to copilot.jl
1 parent 3955014 commit bc33958

File tree

1 file changed

+89
-89
lines changed

1 file changed

+89
-89
lines changed
Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,184 +1,184 @@
11
scriptencoding utf-8
22

3-
let s:has_nvim_ghost_text = has('nvim-0.7') && exists('*nvim_buf_get_mark')
4-
let s:vim_minimum_version = '9.0.0185'
5-
let s:has_vim_ghost_text = has('patch-' . s:vim_minimum_version) && has('textprop')
6-
let s:has_ghost_text = s:has_nvim_ghost_text || s:has_vim_ghost_text
3+
s:has_nvim_ghost_text = has('nvim-0.7') && exists('*nvim_buf_get_mark')
4+
s:vim_minimum_version = '9.0.0185'
5+
s:has_vim_ghost_text = has('patch-' . s:vim_minimum_version) && has('textprop')
6+
s:has_ghost_text = s:has_nvim_ghost_text || s:has_vim_ghost_text
77

8-
let s:hlgroup = 'CopilotSuggestion'
9-
let s:annot_hlgroup = 'CopilotAnnotation'
8+
s:hlgroup = 'CopilotSuggestion'
9+
s:annot_hlgroup = 'CopilotAnnotation'
1010

11-
if s:has_vim_ghost_text && empty(prop_type_get(s:hlgroup))
11+
s:has_vim_ghost_text && empty(prop_type_get(s:hlgroup))
1212
call prop_type_add(s:hlgroup, {'highlight': s:hlgroup})
1313
endif
14-
if s:has_vim_ghost_text && empty(prop_type_get(s:annot_hlgroup))
14+
s:has_vim_ghost_text && empty(prop_type_get(s:annot_hlgroup))
1515
call prop_type_add(s:annot_hlgroup, {'highlight': s:annot_hlgroup})
1616
endif
1717

18-
function! s:Echo(msg) abort
19-
if has('nvim') && &cmdheight == 0
20-
call v:lua.vim.notify(a:msg, v:null, {'title': 'GitHub Copilot'})
21-
else
18+
! s:Echo(msg) abort
19+
has('nvim') && &cmdheight == 0
20+
call v:lua.vim.notify(a:msg, v: , {'title': 'GitHub Copilot'})
21+
2222
echo a:msg
2323
endif
2424
endfunction
2525

26-
function! copilot#Init(...) abort
26+
! copilot#Init(...) abort
2727
call copilot#util#Defer({ -> exists('s:client') || s:Start() })
2828
endfunction
2929

30-
function! s:Running() abort
31-
return exists('s:client.job') || exists('s:client.client_id')
30+
! s:Running() abort
31+
exists('s:client.job') || exists('s:client.client_id')
3232
endfunction
3333

34-
function! s:Start() abort
35-
if s:Running() || exists('s:client.startup_error')
36-
return
34+
! s:Start() abort
35+
s:Running() || exists('s:client.startup_error')
36+
3737
endif
38-
let s:client = copilot#client#New()
38+
s:client = copilot#client#New()
3939
endfunction
4040

41-
function! s:Stop() abort
42-
if exists('s:client')
43-
let client = remove(s:, 'client')
41+
! s:Stop() abort
42+
exists('s:client')
43+
client = remove(s:, 'client')
4444
call client.Close()
4545
endif
4646
endfunction
4747

48-
function! copilot#Client() abort
48+
! copilot#Client() abort
4949
call s:Start()
50-
return s:client
50+
s:client
5151
endfunction
5252

53-
function! copilot#RunningClient() abort
54-
if s:Running()
55-
return s:client
56-
else
57-
return v:null
53+
! copilot#RunningClient() abort
54+
s:Running()
55+
s:client
56+
57+
v:
5858
endif
5959
endfunction
6060

61-
if has('nvim-0.7') && !has(luaeval('vim.version().api_prerelease') ? 'nvim-0.8.1' : 'nvim-0.8.0')
62-
let s:editor_warning = 'Neovim 0.7 support is deprecated and will be dropped in a future release of copilot.vim.'
61+
has('nvim-0.7') && !has(luaeval('vim.version().api_prerelease') ? 'nvim-0.8.1' : 'nvim-0.8.0')
62+
s:editor_warning = 'Neovim 0.7 support is deprecated and will be dropped in a future release of copilot.vim.'
6363
endif
64-
if has('vim_starting') && exists('s:editor_warning')
64+
has('vim_starting') && exists('s:editor_warning')
6565
call copilot#logger#Warn(s:editor_warning)
6666
endif
67-
function! s:EditorVersionWarning() abort
68-
if exists('s:editor_warning')
67+
! s:EditorVersionWarning() abort
68+
exists('s:editor_warning')
6969
echohl WarningMsg
7070
echo 'Warning: ' . s:editor_warning
7171
echohl None
7272
endif
7373
endfunction
7474

75-
function! copilot#Request(method, params, ...) abort
76-
let client = copilot#Client()
77-
return call(client.Request, [a:method, a:params] + a:000)
75+
! copilot#Request(method, params, ...) abort
76+
client = copilot#Client()
77+
call(client.Request, [a:method, a:params] + a:000)
7878
endfunction
7979

80-
function! copilot#Call(method, params, ...) abort
81-
let client = copilot#Client()
82-
return call(client.Call, [a:method, a:params] + a:000)
80+
! copilot#Call(method, params, ...) abort
81+
client = copilot#Client()
82+
call(client.Call, [a:method, a:params] + a:000)
8383
endfunction
8484

85-
function! copilot#Notify(method, params, ...) abort
86-
let client = copilot#Client()
87-
return call(client.Notify, [a:method, a:params] + a:000)
85+
! copilot#Notify(method, params, ...) abort
86+
client = copilot#Client()
87+
call(client.Notify, [a:method, a:params] + a:000)
8888
endfunction
8989

90-
function! copilot#NvimNs() abort
91-
return nvim_create_namespace('github-copilot')
90+
! copilot#NvimNs() abort
91+
nvim_create_namespace('github-copilot')
9292
endfunction
9393

94-
function! copilot#Clear() abort
95-
if exists('g:_copilot_timer')
94+
! copilot#Clear() abort
95+
exists('g:_copilot_timer')
9696
call timer_stop(remove(g:, '_copilot_timer'))
9797
endif
98-
if exists('b:_copilot')
98+
exists('b:_copilot')
9999
call copilot#client#Cancel(get(b:_copilot, 'first', {}))
100100
call copilot#client#Cancel(get(b:_copilot, 'cycling', {}))
101101
endif
102102
call s:UpdatePreview()
103103
unlet! b:_copilot
104-
return ''
104+
''
105105
endfunction
106106

107-
function! copilot#Dismiss() abort
107+
! copilot#Dismiss() abort
108108
call copilot#Clear()
109109
call s:UpdatePreview()
110-
return ''
110+
''
111111
endfunction
112112

113-
let s:filetype_defaults = {
113+
s:filetype_defaults = {
114114
\ 'gitcommit': 0,
115115
\ 'gitrebase': 0,
116116
\ 'hgcommit': 0,
117117
\ 'svn': 0,
118118
\ 'cvs': 0,
119119
\ '.': 0}
120120

121-
function! s:BufferDisabled() abort
122-
if &buftype =~# '^\%(help\|prompt\|quickfix\|terminal\)$'
123-
return 5
121+
! s:BufferDisabled() abort
122+
&buftype =~# '^\%(help\|prompt\|quickfix\|terminal\)$'
123+
5
124124
endif
125-
if exists('b:copilot_disabled')
126-
return empty(b:copilot_disabled) ? 0 : 3
125+
exists('b:copilot_disabled')
126+
empty(b:copilot_disabled) ? 0 : 3
127127
endif
128-
if exists('b:copilot_enabled')
129-
return empty(b:copilot_enabled) ? 4 : 0
128+
exists('b:copilot_enabled')
129+
empty(b:copilot_enabled) ? 4 : 0
130130
endif
131-
let short = empty(&l:filetype) ? '.' : split(&l:filetype, '\.', 1)[0]
132-
let config = {}
133-
if type(get(g:, 'copilot_filetypes')) == v:t_dict
134-
let config = g:copilot_filetypes
131+
short = empty(&l:filetype) ? '.' : split(&l:filetype, '\.', 1)[0]
132+
config = {}
133+
type(get(g:, 'copilot_filetypes')) == v:t_dict
134+
config = g:copilot_filetypes
135135
endif
136-
if has_key(config, &l:filetype)
137-
return empty(config[&l:filetype])
138-
elseif has_key(config, short)
139-
return empty(config[short])
140-
elseif has_key(config, '*')
141-
return empty(config['*'])
142-
else
143-
return get(s:filetype_defaults, short, 1) == 0 ? 2 : 0
136+
has_key(config, &l:filetype)
137+
empty(config[&l:filetype])
138+
has_key(config, short)
139+
empty(config[short])
140+
has_key(config, '*')
141+
empty(config['*'])
142+
143+
get(s:filetype_defaults, short, 1) == 0 ? 2 : 0
144144
endif
145145
endfunction
146146

147-
function! copilot#Enabled() abort
148-
return get(g:, 'copilot_enabled', 1)
147+
! copilot#Enabled() abort
148+
get(g:, 'copilot_enabled', 1)
149149
\ && empty(s:BufferDisabled())
150150
endfunction
151151

152-
let s:inline_invoked = 1
153-
let s:inline_automatic = 2
152+
s:inline_invoked = 1
153+
s:inline_automatic = 2
154154

155-
function! copilot#Complete(...) abort
156-
if exists('g:_copilot_timer')
155+
! copilot#Complete(...) abort
156+
exists('g:_copilot_timer')
157157
call timer_stop(remove(g:, '_copilot_timer'))
158158
endif
159-
let target = [bufnr(''), getbufvar('', 'changedtick'), line('.'), col('.')]
159+
target = [bufnr(''), getbufvar('', 'changedtick'), line('.'), col('.')]
160160
if !exists('b:_copilot.target') || b:_copilot.target !=# target
161-
if exists('b:_copilot.first')
161+
exists('b:_copilot.first')
162162
call copilot#client#Cancel(b:_copilot.first)
163-
endif
163+
end
164164
if exists('b:_copilot.cycling')
165165
call copilot#client#Cancel(b:_copilot.cycling)
166-
endif
167-
let params = {
166+
end
167+
params = {
168168
\ 'textDocument': {'uri': bufnr('')},
169169
\ 'position': copilot#util#AppendPosition(),
170170
\ 'formattingOptions': {'insertSpaces': &expandtab ? v:true : v:false, 'tabSize': shiftwidth()},
171171
\ 'context': {'triggerKind': s:inline_automatic}}
172-
let b:_copilot = {
172+
b:_copilot = {
173173
\ 'target': target,
174174
\ 'params': params,
175175
\ 'first': copilot#Request('textDocument/inlineCompletion', params)}
176-
let g:_copilot_last = b:_copilot
177-
endif
178-
let completion = b:_copilot.first
179-
if !a:0
180-
return completion.Await()
181-
else
176+
g:_copilot_last = b:_copilot
177+
end
178+
completion = b:_copilot.first
179+
!a:0
180+
completion.Await()
181+
182182
call copilot#client#Result(completion, function(a:1, [b:_copilot]))
183183
if a:0 > 1
184184
call copilot#client#Error(completion, function(a:2, [b:_copilot]))

0 commit comments

Comments
 (0)