Skip to content

Commit b7045ed

Browse files
committed
Remove signin, signout, and auth commands
Drop all GitHub/Microsoft authentication: signIn/signOut LSP calls, device code flow, browser-based auth UI, enterprise URI config, and the showDocument/showMessageRequest handlers. The plugin now relies on g:copilot_api_url/g:copilot_api_key for API access.
1 parent 4fa078b commit b7045ed

5 files changed

Lines changed: 3 additions & 156 deletions

File tree

autoload/copilot.vim

Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -536,29 +536,6 @@ function! copilot#AcceptLine(...) abort
536536
return copilot#Accept(a:0 ? a:1 : "\r", "[^\n]\\+")
537537
endfunction
538538

539-
function! copilot#Browser() abort
540-
if type(get(g:, 'copilot_browser')) == v:t_list
541-
let cmd = copy(g:copilot_browser)
542-
elseif type(get(g:, 'open_command')) == v:t_list
543-
let cmd = copy(g:open_command)
544-
elseif has('win32')
545-
let cmd = ['rundll32', 'url.dll,FileProtocolHandler']
546-
elseif has('mac')
547-
let cmd = ['open']
548-
elseif executable('wslview')
549-
return ['wslview']
550-
elseif executable('xdg-open')
551-
return ['xdg-open']
552-
else
553-
return []
554-
endif
555-
if executable(get(cmd, 0, ''))
556-
return cmd
557-
else
558-
return []
559-
endif
560-
endfunction
561-
562539
let s:commands = {}
563540

564541
function! s:EnabledStatusMessage() abort
@@ -623,69 +600,6 @@ function! s:commands.status(opts) abort
623600
call s:EditorVersionWarning()
624601
endfunction
625602

626-
function! s:commands.signout(opts) abort
627-
echo 'Copilot: Signed out'
628-
call copilot#Call('signOut', {})
629-
endfunction
630-
631-
function! s:commands.setup(opts) abort
632-
let startup_error = copilot#Client().StartupError()
633-
if !empty(startup_error)
634-
echo 'Copilot: ' . startup_error
635-
return
636-
endif
637-
638-
let data = copilot#Call('signIn', {})
639-
640-
if has_key(data, 'verificationUri')
641-
let uri = data.verificationUri
642-
if has('clipboard')
643-
try
644-
let @+ = data.userCode
645-
catch
646-
endtry
647-
try
648-
let @* = data.userCode
649-
catch
650-
endtry
651-
endif
652-
let codemsg = "First copy your one-time code: " . data.userCode . "\n"
653-
try
654-
if len(&mouse)
655-
let mouse = &mouse
656-
set mouse=
657-
endif
658-
if get(a:opts, 'bang')
659-
call s:Echo(codemsg . "In your browser, visit " . uri)
660-
let request = copilot#Request('signInConfirm', {})
661-
else
662-
call input(codemsg . "Press ENTER to open GitHub in your browser\n")
663-
let request = copilot#Request('workspace/executeCommand', data.command)
664-
endif
665-
call s:Echo("Waiting for " . data.userCode . " at " . uri . " (could take up to 5 seconds)")
666-
call request.Wait()
667-
finally
668-
if exists('mouse')
669-
let &mouse = mouse
670-
endif
671-
endtry
672-
if request.status ==# 'error'
673-
return 'echoerr ' . string('Copilot: Authentication failure: ' . request.error.message)
674-
else
675-
let data = request.result
676-
endif
677-
elseif get(data, 'status', '') isnot# 'AlreadySignedIn'
678-
return 'echoerr ' . string('Copilot: Something went wrong')
679-
endif
680-
681-
let user = get(data, 'user', '<unknown>')
682-
683-
echo 'Copilot: Authenticated as GitHub user ' . user
684-
endfunction
685-
686-
let s:commands.auth = s:commands.setup
687-
let s:commands.signin = s:commands.setup
688-
689603
function! s:commands.help(opts) abort
690604
return a:opts.mods . ' help ' . (len(a:opts.arg) ? ':Copilot_' . a:opts.arg : 'copilot')
691605
endfunction
@@ -842,17 +756,7 @@ function! copilot#Command(line1, line2, range, bang, mods, arg) abort
842756
if !s:Running()
843757
let cmd = 'restart'
844758
else
845-
try
846-
let opts = copilot#Call('checkStatus', {'options': {'localChecksOnly': v:true}})
847-
if opts.status !=# 'OK' && opts.status !=# 'MaybeOK'
848-
let cmd = 'setup'
849-
else
850-
let cmd = 'status'
851-
endif
852-
catch
853-
call copilot#logger#Exception()
854-
let cmd = 'log'
855-
endtry
759+
let cmd = 'status'
856760
endif
857761
endif
858762
let opts = {'line1': a:line1, 'line2': a:line2, 'range': a:range, 'bang': a:bang, 'mods': a:mods, 'arg': arg}

autoload/copilot/client.vim

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ function! copilot#client#Settings() abort
591591
\ 'http': {
592592
\ 'proxy': get(g:, 'copilot_proxy', v:null),
593593
\ 'proxyStrictSSL': get(g:, 'copilot_proxy_strict_ssl', v:null)},
594-
\ 'github-enterprise': {'uri': get(g:, 'copilot_enterprise_uri', get(g:, 'copilot_auth_provider_url', v:null))},
595594
\ }
596595
if type(settings.http.proxy) ==# v:t_string && settings.http.proxy =~# '^[^/]\+$'
597596
let settings.http.proxy = 'http://' . settings.http.proxy
@@ -686,14 +685,10 @@ let s:notifications = {
686685
\ 'window/logMessage': function('copilot#handlers#window_logMessage'),
687686
\ }
688687

689-
let s:vim_handlers = {
690-
\ 'window/showMessageRequest': function('copilot#handlers#window_showMessageRequest'),
691-
\ 'window/showDocument': function('copilot#handlers#window_showDocument'),
692-
\ }
688+
let s:vim_handlers = {}
693689

694690
let s:vim_capabilities = {
695691
\ 'workspace': {'workspaceFolders': v:true},
696-
\ 'window': {'showDocument': {'support': v:true}},
697692
\ }
698693

699694
function! copilot#client#New() abort

autoload/copilot/handlers.vim

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
11
function! copilot#handlers#window_logMessage(params, ...) abort
22
call copilot#logger#Raw(get(a:params, 'type', 6), get(a:params, 'message', ''))
33
endfunction
4-
5-
function! copilot#handlers#window_showMessageRequest(params, instance, ...) abort
6-
let choice = inputlist([a:instance.name . "\n" . a:params.message . "\n\nRequest Actions:"] +
7-
\ map(copy(get(a:params, 'actions', [])), { i, v -> (i + 1) . '. ' . v.title}))
8-
return choice > 0 ? get(a:params.actions, choice - 1, v:null) : v:null
9-
endfunction
10-
11-
function! s:BrowserCallback(into, code) abort
12-
let a:into.code = a:code
13-
endfunction
14-
15-
function! copilot#handlers#window_showDocument(params, ...) abort
16-
echo a:params.uri
17-
if empty(get(a:params, 'external'))
18-
return {'success': v:false}
19-
endif
20-
let browser = copilot#Browser()
21-
if empty(browser)
22-
return {'success': v:false}
23-
endif
24-
let status = {}
25-
call copilot#job#Stream(browser + [a:params.uri], v:null, v:null, function('s:BrowserCallback', [status]))
26-
let time = reltime()
27-
while empty(status) && reltimefloat(reltime(time)) < 1
28-
sleep 10m
29-
endwhile
30-
return {'success': get(status, 'code') ? v:false : v:true}
31-
endfunction

doc/copilot.txt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
GETTING STARTED *copilot*
44

5-
Invoke `:Copilot setup` to authenticate and enable GitHub Copilot.
6-
75
Suggestions are displayed inline and can be accepted by pressing <Tab>. If
86
inline suggestions do not appear to be working, invoke `:Copilot status` to
97
verify Copilot is enabled and not experiencing any issues.
@@ -16,12 +14,6 @@ COMMANDS *:Copilot*
1614
*:Copilot_enable*
1715
:Copilot enable Re-enable GitHub Copilot after :Copilot disable.
1816

19-
*:Copilot_setup*
20-
:Copilot setup Authenticate and enable GitHub Copilot.
21-
22-
*:Copilot_signout*
23-
:Copilot signout Sign out of GitHub Copilot.
24-
2517
*:Copilot_status*
2618
:Copilot status Check if GitHub Copilot is operational for the current
2719
buffer and report on any issues.
@@ -100,13 +92,6 @@ g:copilot_node_command Tell Copilot what `node` binary to use with
10092
>
10193
let g:copilot_node_command =
10294
\ "~/.nodenv/versions/18.18.0/bin/node"
103-
<
104-
*g:copilot_enterprise_uri*
105-
g:copilot_enterprise_uri
106-
If you are using GitHub Copilot Enterprise, set this
107-
to the URI of your GitHub Enterprise instance.
108-
>
109-
let g:copilot_enterprise_uri = 'https://DOMAIN.ghe.com'
11095
<
11196
*g:copilot_proxy*
11297
g:copilot_proxy Tell Copilot what proxy server to use.

lua/_copilot.lua

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
local copilot = {}
22

3-
local showDocument = function(err, result, ctx, _)
4-
local fallback = vim.lsp.handlers['window/showDocument']
5-
if not fallback or (result.external and vim.g.copilot_browser) then
6-
return vim.fn['copilot#handlers#window_showDocument'](result)
7-
else
8-
return fallback(err, result, ctx, _)
9-
end
10-
end
11-
123
copilot.lsp_start_client = function(cmd, client_name, handler_names, opts, settings)
13-
local handlers = {['window/showDocument'] = showDocument}
4+
local handlers = {}
145
local id
156
for _, name in ipairs(handler_names) do
167
handlers[name] = function(err, result, ctx, _)

0 commit comments

Comments
 (0)