diff options
author | João Távora <joaotavora@gmail.com> | 2022-07-18 21:23:32 +0100 |
---|---|---|
committer | João Távora <joaotavora@gmail.com> | 2022-07-19 17:48:31 +0100 |
commit | 2a12f622dcd69ae7cd2457c8f1fff2b7912dc47d (patch) | |
tree | 84f42e8a875ec5af7942ba5c47e84edb3b1e1d59 /lisp/progmodes | |
parent | 6717589c57edb96c7050df7d33cfcdc805a0eaec (diff) | |
download | emacs-2a12f622dcd69ae7cd2457c8f1fff2b7912dc47d.tar.gz emacs-2a12f622dcd69ae7cd2457c8f1fff2b7912dc47d.tar.bz2 emacs-2a12f622dcd69ae7cd2457c8f1fff2b7912dc47d.zip |
Eglot-workspace-configuration can be a function
* README.md (Workspace configuration): Renamed from per-project
configuration. Rework.
* NEWS.md: Mention change.
* eglot.el (eglot-workspace-configuration): Overhaul.
(eglot-signal-didChangeConfiguration): Use new
eglot-workspace-configuration.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/967
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/eglot.el | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 0b64cd2301b..582ad1fdee8 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2199,12 +2199,22 @@ Records BEG, END and PRE-CHANGE-LENGTH locally." (defvar-local eglot-workspace-configuration () "Alist of (SECTION . VALUE) entries configuring the LSP server. -SECTION should be a keyword or a string, value can be anything -that can be converted to JSON.") +SECTION should be a keyword or a string. VALUE is a +plist or a primitive type converted to JSON. + +The value of this variable can also be a unary function of a +`eglot-lsp-server' instance, the server connection requesting the +configuration. It should return an alist of the format described +above.") ;;;###autoload (put 'eglot-workspace-configuration 'safe-local-variable 'listp) +(defun eglot--workspace-configuration (server) + (if (functionp eglot-workspace-configuration) + (funcall eglot-workspace-configuration server) + eglot-workspace-configuration)) + (defun eglot-signal-didChangeConfiguration (server) "Send a `:workspace/didChangeConfiguration' signal to SERVER. When called interactively, use the currently active server" @@ -2213,7 +2223,7 @@ When called interactively, use the currently active server" server :workspace/didChangeConfiguration (list :settings - (or (cl-loop for (section . v) in eglot-workspace-configuration + (or (cl-loop for (section . v) in (eglot--workspace-configuration server) collect (if (keywordp section) section (intern (format ":%s" section))) @@ -2235,7 +2245,7 @@ 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 + (alist-get section (eglot--workspace-configuration server) nil nil (lambda (wsection section) (string= |