[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot a57d5d8 07/62: Close #29: Implement workspace/did
From: |
Stefan Monnier |
Subject: |
[elpa] externals/eglot a57d5d8 07/62: Close #29: Implement workspace/didChangeConfiguration (#40) |
Date: |
Sat, 29 Sep 2018 17:13:28 -0400 (EDT) |
branch: externals/eglot
commit a57d5d8301d5fadc468e14fedc434d7504e24e24
Author: João Távora <address@hidden>
Commit: GitHub <address@hidden>
Close #29: Implement workspace/didChangeConfiguration (#40)
* README.md (Supported Protocol Features, Commands and
keybindings): mention workspace/didChangeConfiguration.
* eglot.el (eglot-server-initialized-hook): New hook.
(eglot--connect): Run it.
(eglot-workspace-configuration): New variable.
(eglot-signal-didChangeConfiguration): New command.
---
README.md | 7 ++++++-
eglot.el | 22 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 6606db4..a5e9f50 100644
--- a/README.md
+++ b/README.md
@@ -113,6 +113,11 @@ Here's a summary of available commands:
- `M-x eglot-stderr-buffer` if the LSP server is printing useful debug
information in stderr, jumps to a buffer with these contents.
+- `M-x eglot-signal-didChangeConfiguration` updates the LSP server
+configuration according to the value of the variable
+`eglot-workspace-configuration`, which you may, for example set in a
+`.dir-locals` file.`
+
There are *no keybindings* specific to Eglot, but you can bind stuff
in `eglot-mode-map`, which is active as long as Eglot is managing a
file in your project. The commands don't need to be Eglot-specific,
@@ -163,7 +168,7 @@ eglot-shutdown`.
## Workspace
- [ ] workspace/workspaceFolders (3.6.0)
- [ ] workspace/didChangeWorkspaceFolders (3.6.0)
-- [ ] workspace/didChangeConfiguration
+- [x] workspace/didChangeConfiguration
- [ ] workspace/configuration (3.6.0)
- [x] workspace/didChangeWatchedFiles
- [x] workspace/symbol
diff --git a/eglot.el b/eglot.el
index 77f8260..8f9a43d 100644
--- a/eglot.el
+++ b/eglot.el
@@ -446,6 +446,11 @@ INTERACTIVE is t if called interactively."
(defvar eglot-connect-hook nil "Hook run after connecting in
`eglot--connect'.")
+(defvar eglot-server-initialized-hook
+ '(eglot-signal-didChangeConfiguration)
+ "Hook run after server is successfully initialized.
+Each function is passed the server as an argument")
+
(defun eglot--connect (managed-major-mode project class contact)
"Connect to MANAGED-MAJOR-MODE, PROJECT, CLASS and CONTACT.
This docstring appeases checkdoc, that's all."
@@ -514,6 +519,7 @@ This docstring appeases checkdoc, that's all."
(with-current-buffer buffer
(eglot--maybe-activate-editing-mode server)))
(jsonrpc-notify server :initialized `(:__dummy__ t))
+ (run-hook-with-args 'eglot-server-initialized-hook server)
(setf (eglot--inhibit-autoreconnect server)
(cond
((booleanp eglot-autoreconnect) (not eglot-autoreconnect))
@@ -1033,6 +1039,22 @@ Records START, END and PRE-CHANGE-LENGTH locally."
(eglot--signal-textDocument/didChange))))
'((name . eglot--signal-textDocument/didChange)))
+(defvar-local eglot-workspace-configuration ()
+ "Alist of (SETTING . VALUE) entries configuring the LSP server.
+Setting should be a keyword, value can be any value that can be
+converted to JSON.")
+
+(defun eglot-signal-didChangeConfiguration (server)
+ "Send a `:workspace/didChangeConfiguration' signal to SERVER.
+When called interactively, use the currently active server"
+ (interactive (list (eglot--current-server-or-lose)))
+ (jsonrpc-notify
+ server :workspace/didChangeConfiguration
+ (list
+ :settings
+ (cl-loop for (k . v) in eglot-workspace-configuration
+ collect k collect v))))
+
(defun eglot--signal-textDocument/didChange ()
"Send textDocument/didChange to server."
(when eglot--recent-changes
- [elpa] externals/eglot updated (07b235f -> 821b498), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot ad98247 02/62: jsonrpc must be available when compiling, too, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot d936fbd 01/62: Install jsonrpc package when running tests, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 0c85b8f 05/62: Tests only kill server-related buffers when successfull, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 400623f 03/62: Test with Emacs 26.1, not the 26 pre-release, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 5d88eed 06/62: Close #39: Handle experimental/unknown server methods gracefully, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 3ac4b64 04/62: * Makefile (JSONRPC): Call package-refresh-contents, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 8d61eca 09/62: Close #44: Don't turn on flymake-mode any more than is needed, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot a57d5d8 07/62: Close #29: Implement workspace/didChangeConfiguration (#40),
Stefan Monnier <=
- [elpa] externals/eglot 616ad53 13/62: Close #48: be less verbose when using eglot-ensure, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot eeb34c6 21/62: Default eglot-handle-notifictiona|request must &allow-other-keys, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 04f7db7 10/62: Per #48: Fix messages of eglot-ensure, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 5808c0d 11/62: Add entry for haskell-ide-engine in eglot-server-programs (#49), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot ec02ffa 14/62: Work around Emacs bugs 32237, 32278 (#53), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot e476411 19/62: Close #58: Erase company-doc buffer in between doc requests, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot dfaa389 12/62: * README.md (Installation and usage): Add haskell-ide-engine, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot a6cad6b 15/62: Fix typo in willSaveWaitUntil RPC request (#51), Stefan Monnier, 2018/09/29
- [elpa] externals/eglot 2728e12 22/62: Per #59: eglot-workspace-configuration's keys needn't be keywords, Stefan Monnier, 2018/09/29
- [elpa] externals/eglot fd7e587 27/62: Require jsonrpc.el 1.0.2 (GNU ELPA didn't build 1.0.1), Stefan Monnier, 2018/09/29