[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/eglot2emacs a38ce8b28f 052/120: Add simple support for workspace
From: |
João Távora |
Subject: |
feature/eglot2emacs a38ce8b28f 052/120: Add simple support for workspacefolders |
Date: |
Thu, 20 Oct 2022 07:16:52 -0400 (EDT) |
branch: feature/eglot2emacs
commit a38ce8b28fef2f50263d827aedb3394b795dac56
Author: Felicián Németh <felician.nemeth@gmail.com>
Commit: Felicián Németh <felician.nemeth@gmail.com>
Add simple support for workspacefolders
Close https://github.com/joaotavora/eglot/issues/893.
Clients can support workspaceFolders since LSP 3.6. rootUri and
rootPath are deprecated. Dynamic changes in folders are not
supported, i.e., this patch does not implement
workspace/didChangeWorkspaceFolders.
* eglot.el (eglot-client-capabilities): Add capability
`workspaceFolders'.
(eglot-workspace-folders): New cl-defgeneric.
(eglot--connect): Add workspaceFolders to initializeParams.
(eglot-handle-request workspace/workspaceFolders): New cl-defmethod.
---
lisp/progmodes/eglot.el | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
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
- feature/eglot2emacs b931d93b15 085/120: Guess the "lsp identifier at point", (continued)
- feature/eglot2emacs b931d93b15 085/120: Guess the "lsp identifier at point", João Távora, 2022/10/20
- feature/eglot2emacs e5b021c01f 095/120: Fix jdtls support, João Távora, 2022/10/20
- feature/eglot2emacs a598352750 104/120: Allow eglot-workspace-configuration to be a plist, João Távora, 2022/10/20
- feature/eglot2emacs b633c29648 112/120: Rename "eglot -> eglot" in docstrings, João Távora, 2022/10/20
- feature/eglot2emacs 5b902b5cbb 110/120: Add support for "single server, multiple modes", João Távora, 2022/10/20
- feature/eglot2emacs 4071eaf8ad 116/120: * eglot.el (version): actually bump to 1.9, João Távora, 2022/10/20
- feature/eglot2emacs 9801e217f9 118/120: Rework header of eglot.el, João Távora, 2022/10/20
- feature/eglot2emacs 77f3157dcd 048/120: Use new jdtls script for eclipse jdt, João Távora, 2022/10/20
- feature/eglot2emacs 349f6b5f78 050/120: Don't advertise didchangewatchedfiles on tramp, João Távora, 2022/10/20
- feature/eglot2emacs 965e1378f1 053/120: Use bounds of thing at point when asking for code actions, João Távora, 2022/10/20
- feature/eglot2emacs a38ce8b28f 052/120: Add simple support for workspacefolders,
João Távora <=
- feature/eglot2emacs cb562118cb 047/120: Don't strip invisible text when formatting hover string, João Távora, 2022/10/20
- feature/eglot2emacs 904556f662 058/120: Easier initializationoptions in eglot-server-programs, João Távora, 2022/10/20
- feature/eglot2emacs 49e56e47d8 066/120: Solve flymake diagnostics synchronization problems, João Távora, 2022/10/20
- feature/eglot2emacs 917e8ffa31 080/120: Add support for jedi-language-server, João Távora, 2022/10/20
- feature/eglot2emacs 9dbc18cbfa 084/120: Tweak some details, fix some bugs, João Távora, 2022/10/20
- feature/eglot2emacs 2a12f622dc 087/120: Eglot-workspace-configuration can be a function, João Távora, 2022/10/20
- feature/eglot2emacs 1986c4df88 089/120: Reply more reasonably to server's workspace/applyedit, João Távora, 2022/10/20
- feature/eglot2emacs bef332a983 101/120: Adjust last commit about workspace configuration, João Távora, 2022/10/20
- feature/eglot2emacs 523547321e 102/120: Allow :initializationoptions in eglot-server-programs, João Távora, 2022/10/20
- feature/eglot2emacs 68b9c03b44 106/120: Don't use three-argument plist-get, João Távora, 2022/10/20