(put 'eglot--mode-line-format 'risky-local-variable t)
-(defun eglot--mouse-call (what)
- "Make an interactive lambda for calling WHAT from mode-line."
+(defun eglot--mouse-call (what &optional update-mode-line)
+ "Make an interactive lambda for calling WHAT with the mouse."
(lambda (event)
(interactive "e")
(let ((start (event-start event))) (with-selected-window (posn-window start)
(goto-char (or (posn-point start)
(point)))
(call-interactively what)
- (force-mode-line-update t))))))
+ (when update-mode-line
+ (force-mode-line-update t)))))))
(defun eglot-manual () "Open documentation."
(declare (obsolete info "29.1"))
(cl-loop with map = (make-sparse-keymap)
for (elem . rest) on defs
for (key def help) = elem
- do (define-key map `[mode-line ,key] (eglot--mouse-call def))
+ do (define-key map `[mode-line ,key] (eglot--mouse-call def t))
concat (format "%s: %s" key help) into blurb
when rest concat "\n" into blurb
finally (return `(:propertize ,thing
(defalias 'eglot--make-diag 'flymake-make-diagnostic)
(defalias 'eglot--diag-data 'flymake-diagnostic-data)
+(defvar eglot-diagnostics-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [mouse-2] 'eglot-code-actions-at-mouse)
+ map)
+ "Map active in Eglot-backed Flymake diagnostic overlays.")
+
(cl-loop for i from 1
for type in '(eglot-note eglot-warning eglot-error)
do (put type 'flymake-overlay-control
`((mouse-face . highlight)
(priority . ,(+ 50 i))
- (keymap . ,(let ((map (make-sparse-keymap)))
- (define-key map [mouse-1]
- (eglot--mouse-call 'eglot-code-actions))
- map)))))
+ (keymap . ,eglot-diagnostics-map))))
\f
;;; Protocol implementation (Requests, notifications, etc)
(eglot--read-execute-code-action actions server action-kind)
actions)))
+(defalias 'eglot-code-actions-at-mouse (eglot--mouse-call 'eglot-code-actions)
+ "Like `eglot-code-actions', but intended for mouse events.")
+
(defun eglot--read-execute-code-action (actions server &optional action-kind)
"Helper for interactive calls to `eglot-code-actions'."
(let* ((menu-items