Skip to content

Commit 0252be2

Browse files
authored
fix: copilot respects the value of lsp-copilot-enabled (emacs-lsp#4683)
1 parent d2adcdf commit 0252be2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

clients/lsp-copilot.el

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ lsp-install-server to fetch an emacs-local version of the LSP."
5555
:type 'string
5656
:group 'lsp-copilot)
5757

58-
(defcustom lsp-copilot-applicable-fn (-const t)
58+
(defcustom lsp-copilot-applicable-fn (lambda (&rest _) lsp-copilot-enabled)
5959
"A function which returns whether the copilot is applicable for the buffer.
6060
The input are the file name and the major mode of the buffer."
6161
:type 'function
@@ -132,8 +132,10 @@ This function is automatically called during the client initialization if needed
132132
(-let (((&copilot-ls:SignInInitiateResponse? :status :user-code :verification-uri :user) response))
133133

134134
;; Bail if already signed in
135-
(if (s-equals-p status "AlreadySignedIn")
136-
(lsp--info "Copilot :: Already signed in as %s" user)
135+
(cond
136+
((s-equals-p status "AlreadySignedIn")
137+
(lsp--info "Copilot :: Already signed in as %s" user))
138+
((yes-or-no-p "Copilot requires you to log into your Github account. Proceed now?")
137139
(if (display-graphic-p)
138140
(progn
139141
(gui-set-selection 'CLIPBOARD user-code)
@@ -159,7 +161,9 @@ automatically, browse to %s." user-code verification-uri))
159161
(when (s-equals-p status "NotAuthorized")
160162
(user-error "User %s is not authorized" user))
161163

162-
(lsp--info "Authenticated as %s" user))))))))
164+
(lsp--info "Authenticated as %s" user)))
165+
(t
166+
(message "Aborting Copilot login. To avoid being asked again, customize `lsp-copilot-enabled'"))))))))
163167

164168
(defun lsp-copilot-logout ()
165169
"Logout from Copilot."

0 commit comments

Comments
 (0)