From 471434e068816b7d28616aeefa9fe53a5130eca1 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Fri, 4 Oct 2019 10:13:32 +0000 Subject: [PATCH] Don't send dummy json object in "initialized" notification () 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 --- lisp/progmodes/eglot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index cf2f371accd..ef7f8f0a3ec 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -848,7 +848,7 @@ This docstring appeases checkdoc, that's all." (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))) -- 2.39.2