From 6bda52d1ac5b90a2cbf402bcc2565f00249467da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 4 Jun 2018 12:49:28 +0100 Subject: [PATCH] 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 --- lisp/progmodes/eglot.el | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) 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. -- 2.39.2