diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 3bd2d844c8..daf6c3e237 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -654,7 +654,8 @@ treated as in `eglot-dbind'." `(:dynamicRegistration ,(if (eglot--trampish-p s) :json-false t)) :symbol `(:dynamicRegistration :json-false) - :configuration t) + :configuration t + :workspaceFolders t) :textDocument (list :synchronization (list @@ -719,6 +720,15 @@ treated as in `eglot-dbind'." #'car eglot--tag-faces)]))) :experimental eglot--{}))) +(cl-defgeneric eglot-workspace-folders (server) + "Return workspaceFolders for SERVER." + (let ((project (eglot--project server))) + (vconcat + (mapcar (lambda (dir) + (list :uri (eglot--path-to-uri dir) + :name (abbreviate-file-name dir))) + `(,(project-root project) ,@(project-external-roots project)))))) + (defclass eglot-lsp-server (jsonrpc-process-connection) ((project-nickname :documentation "Short nickname for the associated project." @@ -1164,7 +1174,8 @@ This docstring appeases checkdoc, that's all." :rootUri (eglot--path-to-uri default-directory) :initializationOptions (eglot-initialization-options server) - :capabilities (eglot-client-capabilities server)) + :capabilities (eglot-client-capabilities server) + :workspaceFolders (eglot-workspace-folders server)) :success-fn (eglot--lambda ((InitializeResult) capabilities serverInfo) (unless cancelled @@ -1924,6 +1935,11 @@ THINGS are either registrations or unregisterations (sic)." "Handle server request workspace/applyEdit." (eglot--apply-workspace-edit edit eglot-confirm-server-initiated-edits)) +(cl-defmethod eglot-handle-request + (server (_method (eql workspace/workspaceFolders))) + "Handle server request workspace/workspaceFolders." + (eglot-workspace-folders server)) + (defun eglot--TextDocumentIdentifier () "Compute TextDocumentIdentifier object for current buffer." `(:uri ,(eglot--path-to-uri (or buffer-file-name