diff options
| author | João Távora | 2023-02-23 19:18:41 +0000 |
|---|---|---|
| committer | João Távora | 2023-02-23 19:20:34 +0000 |
| commit | 91e24c5b5a69495bcd706a5287c05bb5fd282700 (patch) | |
| tree | 1f5aed2684e180178e42f9e3c8623d5694c98c7b | |
| parent | 79fead1709f8913b6e529c5f4734fcd0c08129c3 (diff) | |
| download | emacs-91e24c5b5a69495bcd706a5287c05bb5fd282700.tar.gz emacs-91e24c5b5a69495bcd706a5287c05bb5fd282700.zip | |
Eglot: update inlay hints on window configuration changes
* lisp/progmodes/eglot.el
(eglot--inlay-hints-after-window-config-change): New helper.
(eglot-inlay-hints-mode): Use it.
| -rw-r--r-- | lisp/progmodes/eglot.el | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 7b4251a1242..eea8be6d1aa 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el | |||
| @@ -3572,6 +3572,9 @@ This value is only meaningful if the minor mode | |||
| 3572 | (window-end window)) | 3572 | (window-end window)) |
| 3573 | (wsetq eglot--inlay-hints-timer nil)))))))))) | 3573 | (wsetq eglot--inlay-hints-timer nil)))))))))) |
| 3574 | 3574 | ||
| 3575 | (defun eglot--inlay-hints-after-window-config-change () | ||
| 3576 | (eglot--update-hints-1 (window-start) (window-end))) | ||
| 3577 | |||
| 3575 | (define-minor-mode eglot-inlay-hints-mode | 3578 | (define-minor-mode eglot-inlay-hints-mode |
| 3576 | "Minor mode for annotating buffers with LSP server's inlay hints." | 3579 | "Minor mode for annotating buffers with LSP server's inlay hints." |
| 3577 | :global nil | 3580 | :global nil |
| @@ -3585,6 +3588,8 @@ This value is only meaningful if the minor mode | |||
| 3585 | #'eglot--inlay-hints-lazily t t) | 3588 | #'eglot--inlay-hints-lazily t t) |
| 3586 | (add-hook 'window-scroll-functions | 3589 | (add-hook 'window-scroll-functions |
| 3587 | #'eglot--inlay-hints-after-scroll nil t) | 3590 | #'eglot--inlay-hints-after-scroll nil t) |
| 3591 | (add-hook 'window-configuration-change-hook | ||
| 3592 | #'eglot--inlay-hints-after-window-config-change nil t) | ||
| 3588 | ;; Maybe there isn't a window yet for current buffer, | 3593 | ;; Maybe there isn't a window yet for current buffer, |
| 3589 | ;; so `run-at-time' ensures this runs after redisplay. | 3594 | ;; so `run-at-time' ensures this runs after redisplay. |
| 3590 | (run-at-time 0 nil #'eglot--inlay-hints-lazily)) | 3595 | (run-at-time 0 nil #'eglot--inlay-hints-lazily)) |
| @@ -3593,6 +3598,8 @@ This value is only meaningful if the minor mode | |||
| 3593 | #'eglot--inlay-hints-fully nil t) | 3598 | #'eglot--inlay-hints-fully nil t) |
| 3594 | (eglot--inlay-hints-fully)))) | 3599 | (eglot--inlay-hints-fully)))) |
| 3595 | (t | 3600 | (t |
| 3601 | (remove-hook 'window-configuration-change-hook | ||
| 3602 | #'eglot--inlay-hints-after-window-config-change) | ||
| 3596 | (remove-hook 'eglot--document-changed-hook | 3603 | (remove-hook 'eglot--document-changed-hook |
| 3597 | #'eglot--inlay-hints-lazily t) | 3604 | #'eglot--inlay-hints-lazily t) |
| 3598 | (remove-hook 'eglot--document-changed-hook | 3605 | (remove-hook 'eglot--document-changed-hook |