From: João Távora Date: Mon, 4 Jun 2018 11:49:28 +0000 (+0100) Subject: Support purposedly ignoring a server capability X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~515 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6bda52d1ac5b90a2cbf402bcc2565f00249467da;p=emacs.git Support purposedly ignoring a server capability * eglot.el (eglot-ignored-server-capabilites): New defcustom. (eglot--server-capable): Use it. GitHub-reference: close https://github.com/joaotavora/eglot/issues/12 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index de8d990f3a0..0869bd52cbf 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -816,16 +816,26 @@ If optional MARKER, return a marker instead" (ignore-errors (funcall mode)) (insert string) (font-lock-ensure) (buffer-string)))) +(defcustom eglot-ignored-server-capabilites (list) + "LSP server capabilities that Eglot could use, but won't. +You could add, for instance, the symbol +`:documentHighlightProvider' to prevent automatic highlighting +under cursor." + :type '(repeat symbol)) + (defun eglot--server-capable (&rest feats) "Determine if current server is capable of FEATS." - (cl-loop for caps = (eglot--capabilities (eglot--current-server-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)))) + (unless (cl-some (lambda (feat) + (memq feat eglot-ignored-server-capabilites)) + feats) + (cl-loop for caps = (eglot--capabilities (eglot--current-server-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.