Skip to content

Commit

Permalink
fix: copilot respects the value of lsp-copilot-enabled (#4683)
Browse files Browse the repository at this point in the history
  • Loading branch information
kassick authored Jan 13, 2025
1 parent d2adcdf commit 0252be2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions clients/lsp-copilot.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ lsp-install-server to fetch an emacs-local version of the LSP."
:type 'string
:group 'lsp-copilot)

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

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

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

(defun lsp-copilot-logout ()
"Logout from Copilot."
Expand Down

0 comments on commit 0252be2

Please sign in to comment.