Function: consult-eglot--transformer

consult-eglot--transformer is a natively compiled function defined in consult-eglot.el.

Signature

(consult-eglot--transformer SYMBOL-INFO)

Documentation

Default transformer to produce a completion candidate from SYMBOL-INFO.

The produced candidate follows the same form as consult--grep however it contains the SYMBOL-INFO as the second field instead of the file URI.

Source Code

;; Defined in /nix/store/3v6wy8b5xagm658m9sa8vhwzkykl5mv6-emacs-packages-deps/share/emacs/site-lisp/elpa/consult-eglot-20260613.1443/consult-eglot.el
(defun consult-eglot--transformer (symbol-info)
  "Default transformer to produce a completion candidate from SYMBOL-INFO.
The produced candidate follows the same form as `consult--grep' however it
contains the SYMBOL-INFO as the second field instead of the file URI."
  (eglot--dbind ((SymbolInformation) name kind location)
      symbol-info
    (eglot--dbind ((Location) uri range) location
      (let* ((line (1+ (plist-get (plist-get range :start) :line)))
             (kind-name (alist-get kind eglot--symbol-kind-names))
             (uri-path (eglot-uri-to-path uri)))
        (propertize
         (concat
          name
          " "
          (string-remove-suffix ":"
                                (consult-eglot--format-file-line-match
                                 ;; If the src is relative to our project directory then use
                                 ;; the path from there, otherwise use the absolute file path.
                                 (let ((relative-uri-path (file-relative-name uri-path)))
                                   (if (string-prefix-p ".." relative-uri-path)
                                       (abbreviate-file-name uri-path)
                                     relative-uri-path))
                                 line)))
         'consult--type (or (car (rassoc kind-name consult-eglot-narrow))
                            (car (rassoc "Other" consult-eglot-narrow)))
         'consult--candidate symbol-info)))))