-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
* 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.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
joaotavora
Author
Owner
|
||
collect k collect v)))) | ||
|
||
(defun eglot--signal-textDocument/didChange () | ||
"Send textDocument/didChange to server." | ||
(when eglot--recent-changes | ||
|
1 comment
on commit a57d5d8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't know what to make of this, @jixiuf
I wonder what the point of this loop is, instead of just passing
eglot-workspace-configuration
directly. Typically, the workspace configuration is a deeply nested JSON object. So the end effect of this special treatment for the outer-level keys is thateglot-workspace-configuration
needs to be a weird mix of alists (with keyword keys...) and plists.