Eglot uses a JSON object { __dummy__ : true } as a placeholder instead
of the empty object {}. It does this out of necessity, since encoding
an empty object can't currently be easily using the current jsonrpc.el
library. However, this also causes the parameter to be actually sent
to the server.
Since the JSON-RPC specification states "The names MUST match exactly,
including case, to the method's expected parameters" this is
non-conforming to the protocol.
The LSP specification does not seem to indicate how servers should
handle method calls with parameters they do not support. As such,
ignoring the parameter, or reporting an error, or crashing all seem to
be "valid" behaviors as far as the specification is concerned.
We can avoid this by using an empty hash table instead of a dummy
parameter. Currently, an empty hash table is the only Emacs Lisp
object which jsonrpc.el serializes to an empty JSON object in
jsonrpc--json-encode.
* eglot.el (eglot--connect): Use make-hash-table instead of dummy
object.
Copyright-paperwork-exempt: yes
GitHub-reference: https://github.com/joaotavora/eglot/issues/312
(push server
(gethash project eglot--servers-by-project))
(setf (eglot--capabilities server) capabilities)
- (jsonrpc-notify server :initialized `(:__dummy__ t))
+ (jsonrpc-notify server :initialized (make-hash-table))
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(eglot--maybe-activate-editing-mode server)))