diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 3d2c267650e..07d64d8209c 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -595,15 +595,16 @@ servers." :type 'boolean) (defface eglot-code-action-indicator-face - '((t (:inherit font-lock-escape-face :weight bold))) + '((t (:inherit warning :weight bold))) "Face used for code action suggestions.") (defcustom eglot-code-action-indications - '(eldoc-hint margin) + '(eldoc-hint left-fringe margin) "How Eglot indicates there's are code actions available at point. Value is a list of symbols, more than one can be specified: - `eldoc-hint': ElDoc is used to hint about at-point actions; +- `left-fringe': A special indicator appears on the left fringe; - `margin': A special indicator appears in the margin; - `nearby': A special indicator appears near point; - `mode-line': A special indicator appears in the mode-line. @@ -612,10 +613,13 @@ If the list is empty, Eglot will not hint about code actions at point. Note additionally: -- `margin' and `nearby' are incompatible. If both are specified, - the latter takes priority; -- `mode-line' only works if `eglot-mode-line-action-suggestion' exists in - `eglot-mode-line-format' (which see)." +- Some values are incompatible; if one or more of `nearby', + `left-fringe' and `margin' are specified, earlier values take + precedence. +- The indicators for many of these are customizable via + `eglot-code-action-indicator' (which see), except for `left-fringe'. +- `mode-line' only works if `eglot-mode-line-action-suggestion' exists + in `eglot-mode-line-format' (which see)." :type '(set :tag "Tick the ones you're interested in" (const :tag "ElDoc textual hint" eldoc-hint) @@ -4720,6 +4724,19 @@ at point. With prefix argument, prompt for ACTION-KIND." (eglot--code-action eglot-code-action-rewrite "refactor.rewrite") (eglot--code-action eglot-code-action-quickfix "quickfix") +(define-fringe-bitmap 'eglot--fringe-action + [#b00000111 + #b00001110 + #b00011100 + #b00111000 + #b01111111 + #b00001110 + #b01011100 + #b01111000 + #b01110000 + #b01111000] + nil nil 'center) + (defun eglot-code-action-suggestion (cb &rest _ignored) "A member of `eldoc-documentation-functions', for suggesting actions." (when (and (eglot-server-capable :codeActionProvider) @@ -4759,13 +4776,19 @@ at point. With prefix argument, prompt for ACTION-KIND." (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))))) + (cond + ((memq 'nearby eglot-code-action-indications) + tooltip) + ((and + (memq 'left-fringe eglot-code-action-indications) + (< 0 (nth 0 (window-fringes)))) + (propertize + "⚡" 'display `(left-fringe + eglot--fringe-action + eglot-code-action-indicator-face))) + ((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)