From: João Távora Date: Sat, 19 May 2018 12:45:10 +0000 (+0100) Subject: Check capabilities before sending :completionitem/resolve X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~554 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=212db69280a825473b8539b1fcafc67587d05d05;p=emacs.git Check capabilities before sending :completionitem/resolve * eglot.el (eglot--server-capable): Rewrite. (eglot-completion-at-point): Check caps before sending :completionItem/resolve --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index e8af7ed80e6..a5c46961317 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -796,9 +796,16 @@ If optional MARKER, return a marker instead" (font-lock-ensure) (buffer-string))))) -(defun eglot--server-capable (feat) - "Determine if current server is capable of FEAT." - (plist-get (eglot--capabilities (eglot--current-process-or-lose)) feat)) +(defun eglot--server-capable (&rest feats) + "Determine if current server is capable of FEATS." + (cl-loop for caps = (eglot--capabilities (eglot--current-process-or-lose)) + then (cadr probe) + for feat in feats + for probe = (plist-member caps feat) + if (not probe) do (cl-return nil) + if (eq (cadr probe) t) do (cl-return t) + if (eq (cadr probe) :json-false) do (cl-return nil) + finally (cl-return (or probe t)))) (defun eglot--range-region (range &optional markers) "Return region (BEG END) that represents LSP RANGE. @@ -1323,9 +1330,11 @@ DUMMY is ignored" (lambda (obj) (let ((documentation (or (get-text-property 0 :documentation obj) - (plist-get (eglot--request proc :completionItem/resolve - (text-properties-at 0 obj)) - :documentation)))) + (and (eglot--server-capable :completionProvider + :resolveProvider) + (plist-get (eglot--request proc :completionItem/resolve + (text-properties-at 0 obj)) + :documentation))))) (when documentation (with-current-buffer (get-buffer-create " *eglot doc*") (erase-buffer)