@@ -163,6 +163,29 @@ You may adjust this variable at your own risk."
163163 (string :tag " Specific Version" ))
164164 :group 'copilot )
165165
166+ (defun copilot--lsp-configuration-changed (symbol value )
167+ " Notify the Copilot LSP configuration has changed and set SYMBOL to VALUE."
168+ (let ((was-bound (boundp symbol)))
169+ (set-default symbol value)
170+ (when was-bound
171+ (copilot--notify-configuration))))
172+
173+ (defcustom copilot-lsp-settings nil
174+ " Settings for the Copilot LSP server.
175+
176+ This value will always be sent to the server when the server starts or the value
177+ changes. See
178+ https://github.com/github/copilot-language-server-release?tab=readme-ov-file#configuration-management
179+ for complete documentation.
180+
181+ For example to use GitHub Enterprise use the following configuration:
182+ '(:github-enterprise (:uri \" https://example.ghe.com\" ))
183+
184+ Exchange the URI with the correct URI of your organization."
185+ :set #'copilot--lsp-configuration-changed
186+ :type 'sexp
187+ :group 'copilot )
188+
166189(defvar-local copilot--overlay nil
167190 " Overlay for Copilot completion." )
168191
@@ -348,6 +371,13 @@ SUCCESS-FN is the CALLBACK."
348371 ; ; handle older jsonrpc versions
349372 (funcall make-fn :events-buffer-scrollback-size copilot-log-max)))))
350373
374+ (defun copilot--notify-configuration ()
375+ " Notify LSP that the configuration has changed.
376+
377+ This should also be called when the connection is established."
378+ (when copilot--connection
379+ (copilot--notify 'workspace/didChangeConfiguration `(:settings , copilot-lsp-settings ))))
380+
351381(defun copilot--start-agent ()
352382 " Start the copilot agent process in local."
353383 (cond
@@ -364,6 +394,7 @@ You can change the installed version with `M-x copilot-reinstall-server` or remo
364394 (copilot--request 'initialize `( :capabilities (:workspace (:workspaceFolders t ))
365395 :processId ,(emacs-pid )))
366396 (copilot--notify 'initialized '())
397+ (copilot--notify-configuration)
367398 (copilot--async-request 'setEditorInfo
368399 `( :editorInfo (:name " Emacs" :version , emacs-version )
369400 :editorPluginInfo (:name " copilot.el" :version ,(or (copilot-installed-version) " unknown" ))
0 commit comments