[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/eglot2emacs a598352750 104/120: Allow eglot-workspace-configurat
From: |
João Távora |
Subject: |
feature/eglot2emacs a598352750 104/120: Allow eglot-workspace-configuration to be a plist |
Date: |
Thu, 20 Oct 2022 07:17:07 -0400 (EDT) |
branch: feature/eglot2emacs
commit a5983527506d0d79137003dc9b5eb15dfd4c7365
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Allow eglot-workspace-configuration to be a plist
Suggested-by: Augusto Stoffel <arstoffel@gmail.com>
* NEWS.md: Mention change.
* README.md (eglot-workspace-configuration): Update yet again. Update
examples to use pylsp.
* eglot.el (eglot--workspace-configuration-plist): Noop if already
a plist.
(eglot-handle-request workspace/configuration): Use
eglot--workspace-configuration-plist.
(eglot-workspace-configuration): Document variable.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/590
GitHub-reference: per https://github.com/joaotavora/eglot/issues/790
GitHub-reference: per https://github.com/joaotavora/eglot/issues/1033
---
lisp/progmodes/eglot.el | 46 +++++++++++++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 13 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 038847c78f..c2db7e817f 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2198,14 +2198,32 @@ Records BEG, END and PRE-CHANGE-LENGTH locally."
'((name . eglot--signal-textDocument/didChange)))
(defvar-local eglot-workspace-configuration ()
- "Alist of (SECTION . VALUE) entries configuring the LSP server.
-SECTION should be a keyword or a string. VALUE is a
-plist or a primitive type converted to JSON.
+ "Configure LSP servers specifically for a given project.
+
+This variable's value should be a plist (SECTION VALUE ...).
+SECTION is a keyword naming a parameter section relevant to a
+particular server. VALUE is a plist or a primitive type
+converted to JSON also understood by that server.
+
+Instead of a plist, an alist ((SECTION . VALUE) ...) can be used
+instead, but this variant is less reliable and not recommended.
+
+This variable should be set as a directory-local variable. See
+See info node `(emacs)Directory Variables' for various ways to to
+that.
+
+Here's an example value that establishes two sections relevant to
+the Pylsp and Gopls LSP servers:
+
+ (:pylsp (:plugins (:jedi_completion (:include_params t
+ :fuzzy t)
+ :pylint (:enabled :json-false)))
+ :gopls (:usePlaceholders t))
The value of this variable can also be a unary function of a
single argument, which will be a connected `eglot-lsp-server'
instance. The function runs with `default-directory' set to the
-root of the current project. It should return an alist of the
+root of the current project. It should return an object of the
format described above.")
;;;###autoload
@@ -2232,12 +2250,15 @@ format described above.")
eglot-workspace-configuration))
(defun eglot--workspace-configuration-plist (server)
- "Returns `eglot-workspace-configuraiton' suitable serialization."
- (or (cl-loop for (section . v) in (eglot--workspace-configuration server)
- collect (if (keywordp section) section
- (intern (format ":%s" section)))
- collect v)
- eglot--{}))
+ "Returns `eglot-workspace-configuration' suitable for serialization."
+ (let ((val (eglot--workspace-configuration server)))
+ (or (and (consp (car val))
+ (cl-loop for (section . v) in val
+ collect (if (keywordp section) section
+ (intern (format ":%s" section)))
+ collect v))
+ val
+ eglot--{})))
(defun eglot-signal-didChangeConfiguration (server)
"Send a `:workspace/didChangeConfiguration' signal to SERVER.
@@ -2264,9 +2285,8 @@ When called interactively, use the currently active
server"
(project-root (eglot--project server)))))
(setq-local major-mode (eglot--major-mode server))
(hack-dir-local-variables-non-file-buffer)
- (alist-get section (eglot--workspace-configuration server)
- nil nil
- (lambda (wsection section)
+ (plist-get (eglot--workspace-configuration-plist server)
section
+ (lambda (section wsection)
(string=
(if (keywordp wsection)
(substring (symbol-name wsection) 1)
- feature/eglot2emacs 05418a1d83 054/120: Add omnisharp support for c#, (continued)
- feature/eglot2emacs 05418a1d83 054/120: Add omnisharp support for c#, João Távora, 2022/10/20
- feature/eglot2emacs c17c3cfcbf 064/120: Check textdocumentsync/willsave cap before sending it, João Távora, 2022/10/20
- feature/eglot2emacs 2dad9298d9 061/120: Rework eglot's mode-line, João Távora, 2022/10/20
- feature/eglot2emacs f9cfefcf89 063/120: Guess language-id if manually entering server program, João Távora, 2022/10/20
- feature/eglot2emacs 339ebe7ce4 065/120: Update invocation for out-of-box dart ls support, João Távora, 2022/10/20
- feature/eglot2emacs 46a480aa88 072/120: Fix egregious thinko in eglot--uri-to-path, João Távora, 2022/10/20
- feature/eglot2emacs f8c8c70f8a 077/120: Reduce eldoc noise from hover messages, João Távora, 2022/10/20
- feature/eglot2emacs 9ffcd537f8 078/120: Apply any additionaltextedits unconditionally, João Távora, 2022/10/20
- 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 <=
- 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, 2022/10/20
- 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