]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a completion-category-defaults entry
authorAugusto Stoffel <arstoffel@gmail.com>
Wed, 28 Apr 2021 10:41:19 +0000 (11:41 +0100)
committerJoão Távora <joaotavora@gmail.com>
Wed, 28 Apr 2021 10:43:57 +0000 (11:43 +0100)
Setting completion-styles buffer-locally is harder to customize and
can break some completion UIs.

Emacs bughttps://github.com/joaotavora/eglot/issues/48073

* eglot.el: Add a completion-category-defaults entry, if applicable.
(eglot--managed-mode): Don't set `completion-styles'
(eglot-completion-at-point): Add style metadata to
completion table.

lisp/progmodes/eglot.el

index 3348054264b7583c6f20288aefc6a31dc7c0d094..122a76b03591972e4e43ee89cc5a2469434ec2a8 100644 (file)
@@ -222,6 +222,10 @@ let the buffer grow forever."
   :type '(choice (const :tag "Don't show confirmation prompt" nil)
                  (symbol :tag "Show confirmation prompt" 'confirm)))
 
+;; Customizable via `completion-category-overrides'.
+(when (assoc 'flex completion-styles-alist)
+  (add-to-list 'completion-category-defaults '(eglot (styles flex basic))))
+
 \f
 ;;; Constants
 ;;;
@@ -1421,8 +1425,6 @@ Use `eglot-managed-p' to determine if current buffer is managed.")
     (eglot--setq-saving flymake-diagnostic-functions '(eglot-flymake-backend))
     (eglot--setq-saving company-backends '(company-capf))
     (eglot--setq-saving company-tooltip-align-annotations t)
-    (when (assoc 'flex completion-styles-alist)
-      (eglot--setq-saving completion-styles '(flex basic)))
     (unless (eglot--stay-out-of-p 'imenu)
       (add-function :before-until (local 'imenu-create-index-function)
                     #'eglot-imenu))
@@ -2166,7 +2168,8 @@ is not active."
                                    (get-text-property 0 'eglot--lsp-item c)
                                    :sortText)
                                   "")))))
-           (metadata `(metadata . ((display-sort-function . ,sort-completions))))
+           (metadata `(metadata (category . eglot)
+                                (display-sort-function . ,sort-completions)))
            resp items (cached-proxies :none)
            (proxies
             (lambda ()