Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delay copilot login check and avoid raising error #4709

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions clients/lsp-copilot.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
:type 'boolean
:group 'lsp-copilot)

(defcustom lsp-copilot-auth-check-delay 5
"How much time to wait before checking if the server is properly authenticated.

Set this value to nil if you do not with for the check to be made."
:type '(choice (const :tag "Do not check" nil)
(integer :tag "Seconds" 5)))

(defcustom lsp-copilot-langserver-command-args '("--stdio")
"Command to start copilot-langserver."
:type '(repeat string)
Expand Down Expand Up @@ -188,8 +195,16 @@ automatically, browse to %s." user-code verification-uri))
(let ((caps (lsp--workspace-server-capabilities workspace)))
(lsp:set-server-capabilities-inline-completion-provider? caps t))

(unless (lsp-copilot--authenticated-as)
(lsp-copilot-login)))

(when lsp-copilot-auth-check-delay
(run-at-time lsp-copilot-auth-check-delay
nil
(lambda ()
(condition-case err
(unless (lsp-copilot--authenticated-as)
(lsp-copilot-login))
(t (lsp--error "Could not authenticate with copilot: %s" (error-message-string err)))))))
t)

;; Server installed by emacs
(lsp-register-client
Expand Down
Loading