From 645bcfc6e57181c39dae1f238758e76c1759a765 Mon Sep 17 00:00:00 2001 From: Joram Schrijver Date: Fri, 13 Sep 2019 11:48:10 +0200 Subject: [PATCH] Treat null/nil server capabilities as false Some language servers may specify null for some capabilities in the list of server capabilities. This does not conform to the specification, but treating it as false is more reasonable than treating it as true. A current example is the PHP language server. which specifies null for every capability it does not handle, like documentHighlightProvider. This would cause Eglot to send constant textDocument/documentHighlight requests, which all timed out. * eglot.el (eglot--server-capable): Change the handling of null values for capabilities to treat them as false instead of true. Copyright-paperwork-exempt: yes --- lisp/progmodes/eglot.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 23d53edc2b2..845f0294dfa 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1101,6 +1101,9 @@ under cursor." for probe = (plist-member caps feat) if (not probe) do (cl-return nil) if (eq (cadr probe) :json-false) do (cl-return nil) + ;; If the server specifies null as the value of the capability, it + ;; makes sense to treat it like false. + if (null (cadr probe)) do (cl-return nil) if (not (listp (cadr probe))) do (cl-return (if more nil (cadr probe))) finally (cl-return (or (cadr probe) t))))) -- 2.39.2