From: Brian Leung Date: Thu, 13 Jan 2022 03:06:18 +0000 (-0800) Subject: Add support for optional completionitem.tags X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~76 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=97107540806a426c0951e572890b2827d41ebd43;p=emacs.git Add support for optional completionitem.tags * eglot.el (eglot--lsp-interface-alist): Add optional CompletionItem.tags. (eglot-completion-at-point): Add :company-deprecated key and value, checking for either the appropriate tag (1) in the :tags property, or a truthy value for the :deprecated property. (eglot-client-capabilities): Advertise tagSupport (for tag == 1) and deprecatedSupport. Also load an updated version of seq.el in Emacsen < 27. * Makefile (ELPA_DEPS): Require latest seq.el. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index d8308e0f978..f109fc930ff 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -7,7 +7,7 @@ ;; Maintainer: João Távora ;; URL: https://github.com/joaotavora/eglot ;; Keywords: convenience, languages -;; Package-Requires: ((emacs "26.1") (jsonrpc "1.0.14") (flymake "1.2.1") (project "0.3.0") (xref "1.0.1") (eldoc "1.11.0")) +;; Package-Requires: ((emacs "26.1") (jsonrpc "1.0.14") (flymake "1.2.1") (project "0.3.0") (xref "1.0.1") (eldoc "1.11.0") (seq "2.23")) ;; This file is part of GNU Emacs. @@ -62,7 +62,6 @@ (require 'imenu) (require 'cl-lib) (require 'project) -(require 'seq) (require 'url-parse) (require 'url-util) (require 'pcase) @@ -85,6 +84,11 @@ (load "eldoc") (require 'eldoc)) +;; Similar issue as above for Emacs 26.3 and seq.el. +(if (< emacs-major-version 27) + (load "seq") + (require 'seq)) + ;; forward-declare, but don't require (Emacs 28 doesn't seem to care) (defvar markdown-fontify-code-blocks-natively) (defvar company-backends) @@ -365,7 +369,7 @@ This can be useful when using docker to run a language server.") (:kind :detail :documentation :deprecated :preselect :sortText :filterText :insertText :insertTextFormat :textEdit :additionalTextEdits :commitCharacters - :command :data)) + :command :data :tags)) (Diagnostic (:range :message) (:severity :code :source :relatedInformation :codeDescription :tags)) (DocumentHighlight (:range) (:kind)) (FileSystemWatcher (:globPattern) (:kind)) @@ -659,7 +663,9 @@ treated as in `eglot-dbind'." `(:snippetSupport ,(if (eglot--snippet-expansion-fn) t - :json-false)) + :json-false) + :deprecatedSupport t + :tagSupport (:valueSet [1])) :contextSupport t) :hover (list :dynamicRegistration :json-false :contentFormat @@ -2461,6 +2467,12 @@ is not active." (kind (alist-get (plist-get lsp-item :kind) eglot--kind-names))) (intern (downcase kind)))) + :company-deprecated + (lambda (proxy) + (when-let ((lsp-item (get-text-property 0 'eglot--lsp-item proxy))) + (or (seq-contains-p (plist-get lsp-item :tags) + 1) + (plist-get lsp-item :deprecated)))) :company-docsig ;; FIXME: autoImportText is specific to the pyright language server (lambda (proxy)