Function: eglot-highlight-eldoc-function
eglot-highlight-eldoc-function is a byte-compiled function defined in
eglot.el.gz.
Signature
(eglot-highlight-eldoc-function CB &rest IGNORED)
Documentation
A member of eldoc-documentation-functions, for highlighting symbols'.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(defun eglot-highlight-eldoc-function (_cb &rest _ignored)
"A member of `eldoc-documentation-functions', for highlighting symbols'."
;; Obviously, we're not using ElDoc for documentation, but merely its
;; at-point calling convention, as shown by the fact that we just
;; ignore cb and return nil to say "no doc".
(when (eglot-server-capable :documentHighlightProvider)
(let ((buf (current-buffer)))
(eglot--async-request
(eglot--current-server-or-lose)
:textDocument/documentHighlight (eglot--TextDocumentPositionParams)
:success-fn
(lambda (highlights)
(mapc #'delete-overlay eglot--highlights)
(setq eglot--highlights nil)
(eglot--when-buffer-window buf
;; Don't highlight occurrences that aren't
;; visible. (bug#80072).
(let* ((w (car (get-buffer-window-list)))
(ws (window-start w)) (we (window-end w))
(ls (1- (line-number-at-pos ws t)))
(le (1- (line-number-at-pos we t))))
(mapc
(eglot--lambda ((DocumentHighlight) range)
(when-let* ((l (cl-getf (cl-getf range :start) :line))
(_ (and (>= l ls) (<= l le))))
(pcase-let ((`(,beg . ,end)
(eglot-range-region range)))
(let ((ov (make-overlay beg end)))
(overlay-put ov 'face 'eglot-highlight-symbol-face)
(overlay-put ov 'eglot--overlay t)
(overlay-put ov 'modification-hooks
`(,(lambda (o &rest _) (delete-overlay o))))
(push ov eglot--highlights)))))
highlights))))
:hint :textDocument/documentHighlight)
nil)))