Eglot: in eglot-code-action-indications, make 'margin' interactive

Didn't know it was possible, thanks to Ergus <spacibba@aol.com> for the
tip about binding [left-margin mouse-2] in the keymap.

The technique adopted in 'eglot-mouse-call' possibly still doesn't work
very well if the margin thing we're clicking on is not on the line point
is currently on.  But we don't have that problem (yet?) because LSP
action suggestions function mostly on a "at point" basis.

* lisp/progmodes/eglot.el (eglot-code-action-indications): Adjust docstring.
(eglot--mouse-call): Don't go anywhere except in text area.
(eglot-diagnostics-map): Bind eglot-mouse-actions to left-margin.
This commit is contained in:
João Távora 2025-01-29 08:33:54 +00:00
parent 2e3b085d44
commit e2ff77052d

View file

@ -595,7 +595,6 @@ Note additionally:
- `margin' and `nearby' are incompatible. If both are specified,
the latter takes priority;
- `margin's indicator is not interactive;
- `mode-line' only works if `eglot-mode-line-action-suggestion' exists in
`eglot-mode-line-format' (which see)."
:type '(set
@ -2214,8 +2213,8 @@ If it is activated, also signal textDocument/didOpen."
(interactive "e")
(let ((start (event-start event))) (with-selected-window (posn-window start)
(save-excursion
(goto-char (or (posn-point start)
(point)))
(unless (posn-area start)
(goto-char (posn-point start)))
(call-interactively what)
(when update-mode-line
(force-mode-line-update t)))))))
@ -2459,6 +2458,7 @@ still unanswered LSP requests to the server\n"))))
(defvar eglot-diagnostics-map
(let ((map (make-sparse-keymap)))
(define-key map [mouse-2] #'eglot-code-actions-at-mouse)
(define-key map [left-margin mouse-2] #'eglot-code-actions-at-mouse)
map)
"Keymap active in Eglot-backed Flymake diagnostic overlays.")