Function: eglot-code-action-suggestion
eglot-code-action-suggestion is a byte-compiled function defined in
eglot.el.gz.
Signature
(eglot-code-action-suggestion CB &rest IGNORED)
Documentation
A member of eldoc-documentation-functions, for suggesting actions.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(defun eglot-code-action-suggestion (cb &rest _ignored)
"A member of `eldoc-documentation-functions', for suggesting actions."
(when (and (eglot-server-capable :codeActionProvider)
eglot-code-action-indications)
(let ((buf (current-buffer))
(bounds (eglot--code-action-bounds))
(use-text-p (memq 'eldoc-hint eglot-code-action-indications))
tooltip blurb)
(eglot--async-request
(eglot--current-server-or-lose)
:textDocument/codeAction
(eglot--code-action-params :beg (car bounds) :end (cadr bounds)
:triggerKind 2)
:success-fn
(lambda (actions)
(eglot--when-buffer-window buf
(delete-overlay eglot--suggestion-overlay)
(when (cl-plusp (length actions))
(setq blurb
(substitute-command-keys
(eglot--format "\\[eglot-code-actions]: %s"
(plist-get (aref actions 0) :title))))
(if (>= (length actions) 2)
(setq blurb (concat blurb (format " (and %s more actions)"
(1- (length actions))))))
(setq tooltip
(propertize eglot-code-action-indicator
'face 'eglot-code-action-indicator-face
'help-echo "mouse-1: execute code actions at point"
'mouse-face 'highlight
'keymap eglot-diagnostics-map))
(save-excursion
(goto-char (car bounds))
(let ((ov (make-overlay (car bounds) (cadr bounds))))
(overlay-put ov 'eglot--actions actions)
(overlay-put ov 'eglot--overlay t)
(overlay-put
ov
'before-string
(cond ((memq 'nearby eglot-code-action-indications)
tooltip)
((memq 'margin eglot-code-action-indications)
(propertize "⚡"
'display
`((margin left-margin)
,tooltip)))))
(setq eglot--suggestion-overlay ov))))
(when use-text-p (funcall cb blurb))))
:hint :textDocument/codeAction)
(and use-text-p t))))